{"id":19150,"date":"2026-04-09T15:57:05","date_gmt":"2026-04-09T15:57:05","guid":{"rendered":"https:\/\/cryptoted.net\/index.php\/2026\/04\/09\/serpent-upgrades-more-fun-stuff\/"},"modified":"2026-04-09T15:57:05","modified_gmt":"2026-04-09T15:57:05","slug":"serpent-upgrades-more-fun-stuff","status":"publish","type":"post","link":"https:\/\/cryptoted.net\/index.php\/2026\/04\/09\/serpent-upgrades-more-fun-stuff\/","title":{"rendered":"Serpent upgrades: More Fun Stuff"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div id=\"\">\n<p class=\"chakra-text css-gi02ar\">Over the past two weeks our primary focus has been getting all of the clients updated to PoC5 compatibility, and it definitely has been a long road. Among the changes to the VM include:<\/p>\n<ul role=\"list\" class=\"css-1ars4k6\">\n<li class=\"css-0\"><b>The new init\/code mechanism<\/b>: basically, when you create a contract, the code provided will execute immediately, and then the return value of that code will be what becomes the contract\u2019s code. This allows us to have contract initialization code, but still keep to the same format of [nonce, price, gas, to, value, data] for both transactions and contract creation, also making it easier to create new contracts via forwarding contracts<\/li>\n<li class=\"css-0\"><b>Reordering transaction and contract data<\/b>: the order is now [nonce, price, gas, to, value, data] in transactions and [gas, to, value, datain, datainsz, dataout, dataoutsz] in messages. Note that Serpent retains the send(to, value, gas), o = msg(to, value, gas, datain, datainsz) and o = msg(to, value, gas, datain, datainsz, dataoutsz) parameters.<\/li>\n<li class=\"css-0\"><b>Fee adjustments<\/b>: transaction creation now has a fee of 500 gas, and several other fees were updated.<\/li>\n<li class=\"css-0\"><b>The CODECOPY and CALLDATACOPY opcodes<\/b>: CODECOPY takes code_index, mem_index, len as arguments, and copies the code from code_index &#8230; code_index+len-1 to memory mem_index &#8230; mem_index+len-1. These are very useful when combined with init\/code. There is also now CODESIZE.<\/li>\n<\/ul>\n<p>The largest changes, however, have been to the architecture surrounding the protocol. On the GUI side, the C++ and Go clients are evolving rapidly, and we will see more updates from that side coming very shortly. If you have been following Ethereum closely, you have likely seen <a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-vezwxf\" href=\"https:\/\/www.youtube.com\/watch?v=ldJcw7JPHz0\">Denny\u2019s Lotto<\/a>, a full implementation of a lottery, plus GUI, written and executed inside the C++ client. From here on, the C++ client will shift toward being a more developer-oriented tool, whereas the Go client will start to focus on being a user-facing application (or rather, meta-application). On the compiler side, Serpent has undergone a number of substantial improvements.<\/p>\n<p class=\"chakra-text css-gi02ar\">First, the code. You can peek into the Serpent compiler under the hood and you will be able to see <a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-vezwxf\" href=\"https:\/\/github.com\/ethereum\/serpent\/blob\/master\/serpent\/compiler.py#L44\">all of the functions<\/a>available, together with their precise translations into EVM code. For example, we have:<\/p>\n<p class=\"chakra-text css-gi02ar\">72: \u00a0\u00a0\u00a0\u00a0[&#8216;access&#8217;, 2, 1,<br \/>\n73: \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0[&#8221;, &#8221;, 32, &#8216;MUL&#8217;, &#8216;ADD&#8217;, &#8216;MLOAD&#8217;]],<\/p>\n<p class=\"chakra-text css-gi02ar\">This means that what access(x,y) is actually doing under the hood is it\u2019s recursively compiling whatever x and y actually are, and then loading the memory at index x + y * 32; hence, x is the pointer to the start of the array and y is the index. This code structure has been around since PoC4, but now I have upgraded the meta-language used to describe translations even further, so as to include even if, while and init\/code in this construction (before they were special cases); now, only set and seq remain as special cases, and if I wanted to I could even remove seq by reimplementing it as a <a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-vezwxf\" href=\"https:\/\/github.com\/ethereum\/serpent\/blob\/master\/serpent\/compiler.py#L203\">rewrite rule<\/a>.<\/p>\n<p class=\"chakra-text css-gi02ar\">The largest changes so far have been for PoC5 compatibility. For example, if you run serpent compile_to_assembly &#8216;return(msg.data[0]*2)&#8217;, you will see:<\/p>\n<p class=\"chakra-text css-gi02ar\">[&#8220;<span class=\"math math-inline\"><span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><semantics><mrow><mi>b<\/mi><mi>e<\/mi><mi>g<\/mi><mi>i<\/mi><mi>n<\/mi><mi>c<\/mi><mi>o<\/mi><mi>d<\/mi><msub><mi>e<\/mi><mn>0<\/mn><\/msub><mi mathvariant=\"normal\">.<\/mi><mi>e<\/mi><mi>n<\/mi><mi>d<\/mi><mi>c<\/mi><mi>o<\/mi><mi>d<\/mi><msub><mi>e<\/mi><mn>0<\/mn><\/msub><mi mathvariant=\"normal\">&#8220;<\/mi><mo separator=\"true\">,<\/mo><mi mathvariant=\"normal\">&#8220;<\/mi><mi>D<\/mi><mi>U<\/mi><mi>P<\/mi><mi mathvariant=\"normal\">&#8220;<\/mi><mo separator=\"true\">,<\/mo><mi mathvariant=\"normal\">&#8220;<\/mi><mi>M<\/mi><mi>S<\/mi><mi>I<\/mi><mi>Z<\/mi><mi>E<\/mi><mi mathvariant=\"normal\">&#8220;<\/mi><mo separator=\"true\">,<\/mo><mi mathvariant=\"normal\">&#8220;<\/mi><mi>S<\/mi><mi>W<\/mi><mi>A<\/mi><mi>P<\/mi><mi mathvariant=\"normal\">&#8220;<\/mi><mo separator=\"true\">,<\/mo><mi mathvariant=\"normal\">&#8220;<\/mi><mi>M<\/mi><mi>S<\/mi><mi>I<\/mi><mi>Z<\/mi><mi>E<\/mi><mi mathvariant=\"normal\">&#8220;<\/mi><mo separator=\"true\">,<\/mo><mi mathvariant=\"normal\">&#8220;<\/mi><\/mrow><annotation encoding=\"application\/x-tex\">begincode_0.endcode_0&#8243;, &#8220;DUP&#8221;, &#8220;MSIZE&#8221;, &#8220;SWAP&#8221;, &#8220;MSIZE&#8221;, &#8220;<\/annotation><\/semantics><\/math><\/span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.8889em;vertical-align:-0.1944em\"\/><span class=\"mord mathnormal\">b<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.03588em\">g<\/span><span class=\"mord mathnormal\">in<\/span><span class=\"mord mathnormal\">co<\/span><span class=\"mord mathnormal\">d<\/span><span class=\"mord\"><span class=\"mord mathnormal\">e<\/span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3011em\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em\"><span class=\"pstrut\" style=\"height:2.7em\"\/><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\">0<\/span><\/span><\/span><\/span><span class=\"vlist-s\">\u200b<\/span><\/span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em\"><span\/><\/span><\/span><\/span><\/span><\/span><span class=\"mord\">.<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mord mathnormal\">n<\/span><span class=\"mord mathnormal\">d<\/span><span class=\"mord mathnormal\">co<\/span><span class=\"mord mathnormal\">d<\/span><span class=\"mord\"><span class=\"mord mathnormal\">e<\/span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3011em\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em\"><span class=\"pstrut\" style=\"height:2.7em\"\/><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\">0<\/span><\/span><\/span><\/span><span class=\"vlist-s\">\u200b<\/span><\/span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em\"><span\/><\/span><\/span><\/span><\/span><\/span><span class=\"mord\">&#8220;<\/span><span class=\"mpunct\">,<\/span><span class=\"mspace\" style=\"margin-right:0.1667em\"\/><span class=\"mord\">&#8220;<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.02778em\">D<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.10903em\">U<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.13889em\">P<\/span><span class=\"mord\">&#8220;<\/span><span class=\"mpunct\">,<\/span><span class=\"mspace\" style=\"margin-right:0.1667em\"\/><span class=\"mord\">&#8220;<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em\">MS<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.07847em\">I<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em\">ZE<\/span><span class=\"mord\">&#8220;<\/span><span class=\"mpunct\">,<\/span><span class=\"mspace\" style=\"margin-right:0.1667em\"\/><span class=\"mord\">&#8220;<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em\">S<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.13889em\">W<\/span><span class=\"mord mathnormal\">A<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.13889em\">P<\/span><span class=\"mord\">&#8220;<\/span><span class=\"mpunct\">,<\/span><span class=\"mspace\" style=\"margin-right:0.1667em\"\/><span class=\"mord\">&#8220;<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em\">MS<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.07847em\">I<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em\">ZE<\/span><span class=\"mord\">&#8220;<\/span><span class=\"mpunct\">,<\/span><span class=\"mspace\" style=\"margin-right:0.1667em\"\/><span class=\"mord\">&#8220;<\/span><\/span><\/span><\/span><\/span>begincode_0&#8243;, &#8220;CALLDATACOPY&#8221;, &#8220;RETURN&#8221;, &#8220;~begincode_0&#8221;, &#8220;#CODE_BEGIN&#8221;, 2, 0, &#8220;CALLDATALOAD&#8221;, &#8220;MUL&#8221;, &#8220;MSIZE&#8221;, &#8220;SWAP&#8221;, &#8220;MSIZE&#8221;, &#8220;MSTORE&#8221;, 32, &#8220;SWAP&#8221;, &#8220;RETURN&#8221;, &#8220;#CODE_END&#8221;, &#8220;~endcode_0&#8221;]<\/p>\n<p class=\"chakra-text css-gi02ar\">The actual code there is just:<\/p>\n<p class=\"chakra-text css-gi02ar\">[2, 0, &#8220;CALLDATALOAD&#8221;, &#8220;MUL&#8221;, &#8220;MSIZE&#8221;, &#8220;SWAP&#8221;, &#8220;MSIZE&#8221;, &#8220;MSTORE&#8221;, 32, &#8220;SWAP&#8221;, &#8220;RETURN&#8221;]<\/p>\n<p class=\"chakra-text css-gi02ar\">If you want to see what\u2019s going on here, suppose that a message is coming in with its first datum being 5. We thus have:<\/p>\n<p class=\"chakra-text css-gi02ar\">2 -&gt; Stack: [2]<br \/>\n0 -&gt; Stack: [2, 0]<br \/>\nCALLDATALOAD -&gt; Stack: [2,5]<br \/>\nMUL -&gt; Stack: [10]<br \/>\nMSIZE -&gt; Stack: [10, 0]<br \/>\nSWAP -&gt; Stack: [0, 10]<br \/>\nMSIZE -&gt; Stack: [0, 10, 0]<br \/>\nMSTORE -&gt; Stack: [0], Memory: [0, 0, 0 &#8230; 10]<br \/>\n32 -&gt; Stack: [0, 32], Memory: [0, 0, 0 &#8230; 10]<br \/>\nSWAP -&gt; Stack: [32, 0], Memory: [0, 0, 0 &#8230; 10]<br \/>\nRETURN<\/p>\n<p class=\"chakra-text css-gi02ar\">The last RETURN returns the 32 memory bytes starting from 0, or [0, 0, 0 &#8230; 10], or the number 10.<\/p>\n<p class=\"chakra-text css-gi02ar\">Now, let\u2019s analyze the wrapper code.<\/p>\n<p class=\"chakra-text css-gi02ar\">[&#8220;<span class=\"math math-inline\"><span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><semantics><mrow><mi>b<\/mi><mi>e<\/mi><mi>g<\/mi><mi>i<\/mi><mi>n<\/mi><mi>c<\/mi><mi>o<\/mi><mi>d<\/mi><msub><mi>e<\/mi><mn>0<\/mn><\/msub><mi mathvariant=\"normal\">.<\/mi><mi>e<\/mi><mi>n<\/mi><mi>d<\/mi><mi>c<\/mi><mi>o<\/mi><mi>d<\/mi><msub><mi>e<\/mi><mn>0<\/mn><\/msub><mi mathvariant=\"normal\">&#8220;<\/mi><mo separator=\"true\">,<\/mo><mi mathvariant=\"normal\">&#8220;<\/mi><mi>D<\/mi><mi>U<\/mi><mi>P<\/mi><mi mathvariant=\"normal\">&#8220;<\/mi><mo separator=\"true\">,<\/mo><mi mathvariant=\"normal\">&#8220;<\/mi><mi>M<\/mi><mi>S<\/mi><mi>I<\/mi><mi>Z<\/mi><mi>E<\/mi><mi mathvariant=\"normal\">&#8220;<\/mi><mo separator=\"true\">,<\/mo><mi mathvariant=\"normal\">&#8220;<\/mi><mi>S<\/mi><mi>W<\/mi><mi>A<\/mi><mi>P<\/mi><mi mathvariant=\"normal\">&#8220;<\/mi><mo separator=\"true\">,<\/mo><mi mathvariant=\"normal\">&#8220;<\/mi><mi>M<\/mi><mi>S<\/mi><mi>I<\/mi><mi>Z<\/mi><mi>E<\/mi><mi mathvariant=\"normal\">&#8220;<\/mi><mo separator=\"true\">,<\/mo><mi mathvariant=\"normal\">&#8220;<\/mi><\/mrow><annotation encoding=\"application\/x-tex\">begincode_0.endcode_0&#8243;, &#8220;DUP&#8221;, &#8220;MSIZE&#8221;, &#8220;SWAP&#8221;, &#8220;MSIZE&#8221;, &#8220;<\/annotation><\/semantics><\/math><\/span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.8889em;vertical-align:-0.1944em\"\/><span class=\"mord mathnormal\">b<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.03588em\">g<\/span><span class=\"mord mathnormal\">in<\/span><span class=\"mord mathnormal\">co<\/span><span class=\"mord mathnormal\">d<\/span><span class=\"mord\"><span class=\"mord mathnormal\">e<\/span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3011em\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em\"><span class=\"pstrut\" style=\"height:2.7em\"\/><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\">0<\/span><\/span><\/span><\/span><span class=\"vlist-s\">\u200b<\/span><\/span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em\"><span\/><\/span><\/span><\/span><\/span><\/span><span class=\"mord\">.<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mord mathnormal\">n<\/span><span class=\"mord mathnormal\">d<\/span><span class=\"mord mathnormal\">co<\/span><span class=\"mord mathnormal\">d<\/span><span class=\"mord\"><span class=\"mord mathnormal\">e<\/span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3011em\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em\"><span class=\"pstrut\" style=\"height:2.7em\"\/><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\">0<\/span><\/span><\/span><\/span><span class=\"vlist-s\">\u200b<\/span><\/span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em\"><span\/><\/span><\/span><\/span><\/span><\/span><span class=\"mord\">&#8220;<\/span><span class=\"mpunct\">,<\/span><span class=\"mspace\" style=\"margin-right:0.1667em\"\/><span class=\"mord\">&#8220;<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.02778em\">D<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.10903em\">U<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.13889em\">P<\/span><span class=\"mord\">&#8220;<\/span><span class=\"mpunct\">,<\/span><span class=\"mspace\" style=\"margin-right:0.1667em\"\/><span class=\"mord\">&#8220;<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em\">MS<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.07847em\">I<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em\">ZE<\/span><span class=\"mord\">&#8220;<\/span><span class=\"mpunct\">,<\/span><span class=\"mspace\" style=\"margin-right:0.1667em\"\/><span class=\"mord\">&#8220;<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em\">S<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.13889em\">W<\/span><span class=\"mord mathnormal\">A<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.13889em\">P<\/span><span class=\"mord\">&#8220;<\/span><span class=\"mpunct\">,<\/span><span class=\"mspace\" style=\"margin-right:0.1667em\"\/><span class=\"mord\">&#8220;<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em\">MS<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.07847em\">I<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.05764em\">ZE<\/span><span class=\"mord\">&#8220;<\/span><span class=\"mpunct\">,<\/span><span class=\"mspace\" style=\"margin-right:0.1667em\"\/><span class=\"mord\">&#8220;<\/span><\/span><\/span><\/span><\/span>begincode_0&#8243;, &#8220;CALLDATACOPY&#8221;, &#8220;RETURN&#8221;, &#8220;~begincode_0&#8221;, &#8220;#CODE_BEGIN&#8221;, &#8230;.. , &#8220;#CODE_END&#8221;, &#8220;~endcode_0&#8221;]<\/p>\n<p class=\"chakra-text css-gi02ar\">I elided the inner code explained above to make things clearer. The first thing we see are two labels, <del class=\"chakra-text css-0\">begincode_0 and<\/del>endcode_0, and the #CODE_BEGIN and #CODE_END guards. The labels mark the beginning and end of the inner code, and the guards are there for the later stages of the compiler, which understands that everything between the guards should be compiled as if it is a separate program. Now, let\u2019s look at the first parts of the code. In this case, we have ~begincode_0 at position 10 and ~endcode_0 at position 24 in the final code. <span class=\"math math-inline\"><span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http:\/\/www.w3.org\/1998\/Math\/MathML\"><semantics><mrow><mi>b<\/mi><mi>e<\/mi><mi>g<\/mi><mi>i<\/mi><mi>n<\/mi><mi>c<\/mi><mi>o<\/mi><mi>d<\/mi><msub><mi>e<\/mi><mn>0<\/mn><\/msub><mi>a<\/mi><mi>n<\/mi><mi>d<\/mi><\/mrow><annotation encoding=\"application\/x-tex\">begincode_0 and <\/annotation><\/semantics><\/math><\/span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.8889em;vertical-align:-0.1944em\"\/><span class=\"mord mathnormal\">b<\/span><span class=\"mord mathnormal\">e<\/span><span class=\"mord mathnormal\" style=\"margin-right:0.03588em\">g<\/span><span class=\"mord mathnormal\">in<\/span><span class=\"mord mathnormal\">co<\/span><span class=\"mord mathnormal\">d<\/span><span class=\"mord\"><span class=\"mord mathnormal\">e<\/span><span class=\"msupsub\"><span class=\"vlist-t vlist-t2\"><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.3011em\"><span style=\"top:-2.55em;margin-left:0em;margin-right:0.05em\"><span class=\"pstrut\" style=\"height:2.7em\"\/><span class=\"sizing reset-size6 size3 mtight\"><span class=\"mord mtight\">0<\/span><\/span><\/span><\/span><span class=\"vlist-s\">\u200b<\/span><\/span><span class=\"vlist-r\"><span class=\"vlist\" style=\"height:0.15em\"><span\/><\/span><\/span><\/span><\/span><\/span><span class=\"mord mathnormal\">an<\/span><span class=\"mord mathnormal\">d<\/span><\/span><\/span><\/span><\/span>endcode_0 are used to refer to these positions, and $begincode_0.endcode_0 refers to the length of the interval between them, 14. Now, remember that during contract initialization the call data is the code that you\u2019re feeding in. Thus, we have:<\/p>\n<p class=\"chakra-text css-gi02ar\">14 -&gt; Stack: [14]<br \/>\nDUP -&gt; Stack: [14, 14]<br \/>\nMSIZE -&gt; Stack: [14, 14, 0]<br \/>\nSWAP -&gt; Stack: [14, 0, 14]<br \/>\nMSIZE -&gt; Stack: [14, 0, 14, 0]<br \/>\n10 -&gt; Stack: [14, 0, 14, 0, 10]<br \/>\nCALLDATACOPY -&gt; Stack: [14, 0] Memory: [ &#8230; ]<br \/>\nRETURN<\/p>\n<p class=\"chakra-text css-gi02ar\">Notice how the first half of the code cleverly set up the stack so that it would push the inner code into memory indices 0\u202613, and then immediately return that chunk of memory. In the final compiled code,600e515b525b600a37f26002600035025b525b54602052f2, the inner code sits nicely to the right of the initializer code that simply returns it. In more complex contracts, initializers can also serve functions like setting certain storage slots to values, or even calling or creating other contracts.<\/p>\n<p class=\"chakra-text css-gi02ar\">Now, let us introduce the latest and most fun feature of Serpent: imports. One common use case in contract land is that you want to give a contract the ability to spawn off new contracts. Problem is, how to you put the code for the spawned contracts into the spawner contracts? Before, the only solution was the uncomfortable approach of compiling the newer contracts first, and then putting the compiled code into an array. Now, we have a better solution: import.<\/p>\n<p class=\"chakra-text css-gi02ar\">Put the following into returnten.se:<\/p>\n<p class=\"chakra-text css-gi02ar\">x = create(tx.gas &#8211; 100, 0, import(mul2.se))<br \/>\nreturn(msg(x,0,tx.gas-100,[5],1))<\/p>\n<p class=\"chakra-text css-gi02ar\">Now, put the following into mul2.se:<\/p>\n<p class=\"chakra-text css-gi02ar\">return(msg.data[0]*2)<\/p>\n<p class=\"chakra-text css-gi02ar\">Now, if you serpent compile returnten.se and <a class=\"chakra-link css-vezwxf\" href=\"https:\/\/blog.ethereum.org\/2014\/04\/10\/pyethereum-and-serpent-programming-guide\">run the contract<\/a>, you notice that, voila, it returns ten. The reason why is obvious. The returnten.se contract creates an instance of the mul2.se contract, and then calls it with the value 5. mul2.se, as the name suggests, is a doubler, and so it returns 5*2 = 10. Note that import is not a function in the standard sense; x = import(&#8216;123.se&#8217;) will fail, and import only works in the very specific context of create.<\/p>\n<p class=\"chakra-text css-gi02ar\">Now, suppose you are creating a 1000-line monster contract and want to split it up into files. To do that, we use inset. Intoouter.se, put:<\/p>\n<p class=\"chakra-text css-gi02ar\">if msg.data[0] == 1:<br \/>\ninset(inner.se)<\/p>\n<p class=\"chakra-text css-gi02ar\">And into inner.se, put:<\/p>\n<p class=\"chakra-text css-gi02ar\">return(3)<\/p>\n<p class=\"chakra-text css-gi02ar\">Running serpent compile outer.se gives you a nice piece of compiled code that returns 3 if the msg.data[0] argument is equal to one. And that\u2019s all there is to it.<\/p>\n<p class=\"chakra-text css-gi02ar\">Upcoming updates to Serpent include:<\/p>\n<ul role=\"list\" class=\"css-1ars4k6\">\n<li class=\"css-0\">An improvement of this mechanism so it doesn\u2019t load the inner code twice if you try to use import twice with the same filename<\/li>\n<li class=\"css-0\">String literals<\/li>\n<li class=\"css-0\">Space and code-efficiency improvements for array literals<\/li>\n<li class=\"css-0\">A debugging decorator (ie. a compiling function which tells you what lines of Serpent correspond to what bytes of compiled code)<\/li>\n<\/ul>\n<p>In the short term, though, my own effort will focus on bugfixes, a cross-client test suite, and continued work on <a target=\"_blank\" rel=\"noopener\" class=\"chakra-link css-vezwxf\" href=\"https:\/\/github.com\/ethereum\/ethereumjs-lib\">ethereumjs-lib<\/a>.<\/div>\n<p><br \/>\n<br \/><a href=\"https:\/\/blog.ethereum.org\/en\/2014\/05\/02\/serpent-upgrades-more-fun-stuff\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over the past two weeks our primary focus has been getting all of the clients updated to PoC5 compatibility, and it definitely has been a long road. Among the changes to the VM include: The new init\/code mechanism: basically, when you create a contract, the code provided will execute immediately, and then the return value [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":18498,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"tdm_status":"","tdm_grid_status":"","footnotes":""},"categories":[24],"tags":[],"kronos_expire_date":[],"class_list":["post-19150","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ethereum"],"_links":{"self":[{"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/posts\/19150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/comments?post=19150"}],"version-history":[{"count":0,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/posts\/19150\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/media\/18498"}],"wp:attachment":[{"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/media?parent=19150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/categories?post=19150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/tags?post=19150"},{"taxonomy":"kronos_expire_date","embeddable":true,"href":"https:\/\/cryptoted.net\/index.php\/wp-json\/wp\/v2\/kronos_expire_date?post=19150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}