What's a syntax? MonolithicModulation script. [ Solidity, SeedTree, fixation ]
0x0D89
December 7th, 2021

This ~8 minute read explains how to structure a basic “beget.sol” Solidity smart contract dataset using SeedTree organizing principles.

What’s Solidity?

Solidity is the most popular language that directly instructs the Ethereum Virtual Machine (“EVM”). Solidity is Turing-complete “contract source code.”

Solidity is a relatively unique language, and for good reason.

In most Turing-complete machine environments, the machine does not charge a transaction fee to run a command. However, in an EVM environment, the machine does charge a transaction fee to run a command.

This means writing and rewriting stored datasets also requires transaction logic, and that extra logic has a substantial impact on which types of generalized patterns work well with Solidity.

Here is an example of how this transaction logic “laissez-faire” remedied the harm CryptoKitties accidentally caused when it became too viral for EVM to handle. Because of this economic correction, there was no need to restart or fork EVM.

What’s SeedTree?

SeedTree is a high-level language abstraction philosophy. The philosophy is an evolving mixture of theory and practice that includes the following organizing principles:

  • Algebraic text is the universal interface. (minimalism)
  • Distinguish verbs from nouns as much as possible. (aeffect)
  • Nonhalting can be positive or negative, depending on context; halted can be positive or negative, depending on context. (flow)
  • A { key (pointer)→ value } pair [including an arrayed n++ key] is the lowest level object. (link)
  • Information is recursive and information is fractal. (LIFO-forest)
  • The first instance of a recursion has a unique position. (FIFO)
  • These organizing principles should facilitate as unopinionated as possible simple-&-easy processes that extend a namespace without increasing the risk of name collision. (loci)

The SeedTree philosophy began by exploring how to better abstract the JavaScript language, a language that does not charge a transaction fee to run commands.

What’s beget.sol?

This beget.sol script is running here (initialized) and here (not yet initialized).

beget.sol

000 | // SPDX-License-Identifier: GPL-3.0
001 | pragma solidity >=0.7.0 <0.9.0
002 | ;
003 | contract dataset {
004 |     function child( string calldata $0 ) external {
005 |         require(
006 |             _x[ 0 ].initialized
007 |             , 'NOT_YET_INITIALIZED'
008 |         )
009 |         ; _x[ 0 ].count ++
010 |         ; x[ 0 ] = _1(
011 |             _x[ 0 ].count
012 |             , _x[ 0 ].publisher
013 |             , _x[ 0 ].text
014 |             , 3
015 |         )
016 |         ; x[ _x[ 0 ].count ] = _1(
017 |             _x[ 0 ].count
018 |             , msg.sender
019 |             , $0
020 |             , 4
021 |         )
022 |         ;
023 |     }
024 |     constructor() {
025 |         _x[ 0 ].count = 0
026 |         ; _x[ 0 ].initialized = false
027 |         ; _x[ 0 ].publisher = msg.sender
028 |         ; _x[ 0 ].text = 'hello world'
029 |         ;
030 |     }
031 |     function parent( string calldata $0 ) external {
032 |         require(
033 |             msg.sender == _x[ 0 ].publisher
034 |             , 'NOT_PUBLISHER_CANNOT_EDIT'
035 |         )
036 |         ;
037 |         if ( ! _x[ 0 ].initialized ) {
038 |             _x[ 0 ].initialized = true
039 |             ; _x[ 0 ] = _0(
040 |                 _x[ 0 ].count
041 |                 , _x[ 0 ].initialized
042 |                 , _x[ 0 ].publisher
043 |                 , $0
044 |                 , _x[ 0 ].text
045 |             )           
046 |             ; x[ 0 ] = _1(
047 |                 _x[ 0 ].count
048 |                 , _x[ 0 ].publisher
049 |                 , _x[ 0 ].text
050 |                 , 1
051 |             )
052 |             ; return
053 |             ;
054 |         }
055 |         _x[ 0 ] = _0(
056 |             _x[ 0 ].count
057 |             , _x[ 0 ].initialized
058 |             , _x[ 0 ].publisher
059 |             , _x[ 0 ].secret
060 |             , $0
061 |         )
062 |         ; x[ 0 ] = _1(
063 |             _x[ 0 ].count
064 |             , _x[ 0 ].publisher
065 |             , _x[ 0 ].text
066 |             , 2
067 |         )
068 |         ;
069 |     }
070 |     mapping( uint256 => _0 ) private _x
071 |     ; mapping( uint256 => _1 ) public x
072 |     ;
073 |     function count() public view returns ( uint256 ) {
074 |         return x[ 0 ].count
075 |         ;
076 |     }
077 |     function initialized() public view returns ( bool ) {
078 |         return _x[ 0 ].initialized
079 |         ;
080 |     }
081 |     function secret() public view returns ( string memory ) {
082 |         if ( msg.sender != _x[ 0 ].publisher ) {
083 |             return 'NOT_PUBLISHER_CANNOT_SEE'
084 |             ;
085 |         }
086 |         return _x[ 0 ].secret
087 |         ;
088 |     }
089 |     struct _0 {
090 |         uint256 count
091 |         ; bool initialized
092 |         ; address publisher
093 |         ; string secret
094 |         ; string text
095 |         ;
096 |     }
097 |     struct _1 {
098 |         uint256 count
099 |         ; address publisher
100 |         ; string text
101 |         ; uint256 version
102 |         ;
103 |     }
104 | }
105 | 

prototype

The parent prototype is _0 and the child prototype is _1.

089 |     struct _0 {
090 |         uint256 count
091 |         ; bool initialized
092 |         ; address publisher
093 |         ; string secret
094 |         ; string text
095 |         ;
096 |     }
097 |     struct _1 {
098 |         uint256 count
099 |         ; address publisher
100 |         ; string text
101 |         ; uint256 version
102 |         ;
103 |     } 

These _0 and _1 prototypes are called within an explicitly defined array via the _x and x mapping wrappers, with _x[ 0 ] as the private parent and x as the public parent that stores its metadata object at the x[ 0 ] first instance address.

Notice that _1 has a version variable within it. This variable is used to track which part of the script last wrote or rewrote x[ 0 ].

070 |     mapping( uint256 => _0 ) private _x
071 |     ; mapping( uint256 => _1 ) public x
072 |     ;

When the contract is formed, _x[ 0 ] is first populated with constructor (Solidity somewhat unconventionally defines “constructor,” compared to other languages).

024 |     constructor() {
025 |         _x[ 0 ].count = 0
026 |         ; _x[ 0 ].initialized = false
027 |         ; _x[ 0 ].publisher = msg.sender
028 |         ; _x[ 0 ].text = 'hello world'
029 |         ;
030 |     }

After contract formation, the publisher must manually run parent( $0 ) to initialize the contract, with $0 being the secret string only the publisher can retrieve later.

037 |         if ( ! _x[ 0 ].initialized ) {
038 |             _x[ 0 ].initialized = true
039 |             ; _x[ 0 ] = _0(
040 |                 _x[ 0 ].count
041 |                 , _x[ 0 ].initialized
042 |                 , _x[ 0 ].publisher
043 |                 , $0
044 |                 , _x[ 0 ].text
045 |             )           
046 |             ; x[ 0 ] = _1(
047 |                 _x[ 0 ].count
048 |                 , _x[ 0 ].publisher
049 |                 , _x[ 0 ].text
050 |                 , 1
051 |             )
052 |             ; return
053 |             ;
054 |         }

The child function will not run until the contract is initialized.

005 |         require(
006 |             _x[ 0 ].initialized
007 |             , 'NOT_YET_INITIALIZED'
008 |         )

After initialization, _x and x are modified by the parent and child functions.

_x and x modifications within the parent function:

055 |         _x[ 0 ] = _0(
056 |             _x[ 0 ].count
057 |             , _x[ 0 ].initialized
058 |             , _x[ 0 ].publisher
059 |             , _x[ 0 ].secret
060 |             , $0
061 |         )
062 |         ; x[ 0 ] = _1(
063 |             _x[ 0 ].count
064 |             , _x[ 0 ].publisher
065 |             , _x[ 0 ].text
066 |             , 2
067 |         )
068 |         ;

_x and x modifications within the child function:

009 |         ; _x[ 0 ].count ++
010 |         ; x[ 0 ] = _1(
011 |             _x[ 0 ].count
012 |             , _x[ 0 ].publisher
013 |             , _x[ 0 ].text
014 |             , 3
015 |         )
016 |         ; x[ _x[ 0 ].count ] = _1(
017 |             _x[ 0 ].count
018 |             , msg.sender
019 |             , $0
020 |             , 4
021 |         )
022 |         ;

The following lines UI expose specific key:value pairs for the count, initialized and secret keys.

073 |     function count() public view returns ( uint256 ) {
074 |         return x[ 0 ].count
075 |         ;
076 |     }
077 |     function initialized() public view returns ( bool ) {
078 |         return _x[ 0 ].initialized
079 |         ;
080 |     }
081 |     function secret() public view returns ( string memory ) {
082 |         if ( msg.sender != _x[ 0 ].publisher ) {
083 |             return 'NOT_PUBLISHER_CANNOT_SEE'
084 |             ;
085 |         }
086 |         return _x[ 0 ].secret
087 |         ;
088 |     }

What’s fixation?

Fixation is a very useful copyright concept that helps keep abstraction paradigms more concrete.

According to 17 U.S.C. §101, a work is fixated “when its embodiment in a copy or phonorecord is sufficiently permanent or stable to permit it to be perceived, reproduced or otherwise communicated for a period of more than transitory duration.”

Another way to look at this is that generalizations can only be conveyed through specific examples and case studies, some better suited at conveying a generality than others.

What generalizations are conveyed within the beget.sol fixation?

SeedTree philosophy applied to smart contract patterns within beget.sol:

  • The concept of initialization after contract formation, when parent is first called. (loci)
  • A global private parent object _x and a global public parent object x. (dimonolith)
  • The first entry x[ 0 ] in the global public parent object is the parent object’s metadata child. (FIFO)
  • Each x[] entry wrapped within the global public parent object is a child object pushed into the global public parent object whenever child is called. (modular)
  • At parent( $0 ) initialization, the publisher has the option to store a secret string $0 within the global private object that only the publisher can retrieve later. (permission)
  • After initialization, a parent call modifies the first entry x[ 0 ] within the global public parent object. (metadata)

conclusion

_x[ 0 ].secret in beget.sol is not truly secret because there is no random object to properly seed secrecy generation. Here is an example of that reality on Etherscan.

It seems no true secret is begettable without actual randomness included somewhere.

Compare this necessity of a randomness value for privately siloed meaning inside a genuinely public ledger with Schrödinger’s “What is life?” order-from-disorder & order-from-order process juxtaposition.

To support ape.mirror.xyz , please consider buying an NFT of this “cyberpoetic” document:

.

Arweave TX
jEPLJETk9zkm2d7mT6xY01bdyOlJld5Dz3a-O1uuERQ
Ethereum Address
0x0D89421D6eec0A4385F95f410732186A2Ab45077
Content Digest
0GcDDHirHvEpKS3PbHKm3d-ATeSlDlqOWoJObOBLpwY