<divclass="link title"><ahref="/v5/">Documentation</a></div><divclass="base show link depth-1"><ahref="/v5/getting-started/">Getting Started</a></div><divclass="base show link depth-1"><ahref="/v5/concepts/">Ethereum Basics</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/events/">Events</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/gas/">Gas</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/security/">Security</a></div><divclass="hide link depth-2"><ahref="/v5/concepts/best-practices/">Best Practices</a></div><divclass="base show link depth-1"><ahref="/v5/api-keys/">Provider API Keys</a></div><divclass="base ancestor show link depth-1"><ahref="/v5/api/">Application Programming Interface</a></div><divclass="show link depth-2"><ahref="/v5/api/providers/">Providers</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/provider/">Provider</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/api-providers/">API Providers</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/other/">Other Providers</a></div><divclass="hide link depth-3"><ahref="/v5/api/providers/types/">Types</a></div><divclass="show link depth-2"><ahref="/v5/api/signer/">Signers</a></div><divclass="show link depth-2"><ahref="/v5/api/contract/">Contract Interaction</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/contract/">Contract</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/contract-factory/">ContractFactory</a></div><divclass="hide link depth-3"><ahref="/v5/api/contract/example/">Example: ERC-20 Contract</a></div><divclass="show link depth-2"><ahref="/v5/api/utils/">Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/abi/">Application Binary Interface</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/coder/">AbiCoder</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/formats/">ABI Formats</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/fragments/">Fragments</a></div><divclass="hide link depth-4"><ahref="/v5/api/utils/abi/interface/">Interface</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/address/">Addresses</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/bignumber/">BigNumber</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/bytes/">Byte Manipulation</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/constants/">Constants</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/display-logic/">Display Logic and Input</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/encoding/">Encoding Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/hashing/">Hashing Algorithms</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/hdnode/">HD Wallet</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/logger/">Logging</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/properties/">Property Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/signing-key/">Signing Key</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/strings/">Strings</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/transactions/">Transactions</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/web/">Web Utilities</a></div><divclass="hide link depth-3"><ahref="/v5/api/utils/wordlists/">Wordlists</a></div><divclass="ancestor show link depth-2"><ahref="/v5/api/other/">Other Libraries</a></div><divclass="ancestor show link depth-3"><ahref="/v5/api/other/assembly/">Assembly</a></div><divclass="show link depth-4"><ahref="/v5/api/other/assembly/dialect/">Ethers ASM Dialect</a></div><divclass="show link depth-4"><ahref="/v5/api/other/assembly/api/">Utilities</a></div><divclass="myselfancestorancestorsho
<aname="asm-ast"></a><aname="asm-ast"></a><h1class="show-anchors"><div>Abstract Syntax Tree<divclass="anchors"><aclass="self"href="/v5/api/other/assembly/ast/#asm-ast"></a></div></div></h1><p>Parsing a file using the <ahref="/v5/api/other/assembly/dialect/">Ethers ASM Dialect</a> will generate an Abstract Syntax Tree. The root node will always be a <ahref="/v5/api/other/assembly/ast/#asm-scopenode">ScopeNode</a> whose name is <codeclass="inline">_</code>.</p>
<p>To parse a file into an Abstract Syntax tree, use the <ahref="/v5/api/other/assembly/api/#asm-parse">parse</a> function.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="method">offset</span><spanclass="arrow">⇒</span><spanclass="returns">number</span><divclass="anchors"></div></div><divclass="body"><p>The offset into the source code to the start of this node.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="method">length</span><spanclass="arrow">⇒</span><spanclass="returns">number</span><divclass="anchors"></div></div><divclass="body"><p>The length of characters in the source code to the end of this node.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="method">source</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>The source code of this node.</p>
</div></div><aname="asm-ast--nodes"></a><h2class="show-anchors"><div>Nodes<divclass="anchors"><aclass="self"href="/v5/api/other/assembly/ast/#asm-ast--nodes"></a></div></div></h2><p>@TODO: Place a diagram here showing the hierarchy</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">node</span><spanclass="symbol">.</span><spanclass="method">tag</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>A unique tag for this node for the lifetime of the process.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">node</span><spanclass="symbol">.</span><spanclass="method">location</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/other/assembly/ast/#asm-location">Location</a></span><divclass="anchors"></div></div><divclass="body"><p>The source code and location within the source code that this node represents.</p>
</div></div><aname="asm-valuenode"></a><aname="asm-ast--nodes--asm-valuenode"></a><h3class="show-anchors"><div>ValueNode<spanclass="inherits"> inherits <ahref="/v5/api/other/assembly/ast/#asm-node">Node</a></span><divclass="anchors"><aclass="self"href="/v5/api/other/assembly/ast/#asm-valuenode"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/asm/src.ts/assembler.ts#L213">source</a></div></div></h3><p>A <b>ValueNode</b> is a node which may manipulate the stack.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">literalNode</span><spanclass="symbol">.</span><spanclass="method">value</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>The literal value of this node, which may be a <ahref="/v5/api/utils/bytes/#DataHexString">DataHexString</a> or string of a decimal number.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">literalNode</span><spanclass="symbol">.</span><spanclass="method">verbatim</span><spanclass="arrow">⇒</span><spanclass="returns">boolean</span><divclass="anchors"></div></div><divclass="body"><p>This is true in a <ahref="/v5/api/other/assembly/ast/#asm-datanode">DataNode</a> context, since in that case the value should be taken verbatim and no <codeclass="inline">PUSH</code> operation should be added, otherwise false.</p>
</div></div><aname="asm-popnode"></a><aname="asm-ast--nodes--asm-popnode"></a><h3class="show-anchors"><div>PopNode<spanclass="inherits"> inherits <ahref="/v5/api/other/assembly/ast/#asm-valuenode">ValueNode</a></span><divclass="anchors"><aclass="self"href="/v5/api/other/assembly/ast/#asm-popnode"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/asm/src.ts/assembler.ts#L265">source</a></div></div></h3><p>A <b>PopNode</b> is used to store a place-holder for an implicit pop from the stack. It represents the code for an implicit place-holder (i.e. <codeclass="inline">$$</code>) or an explicit place-holder (e.g. <codeclass="inline">$1</code>), which indicates the expected stack position to consume.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">literalNode</span><spanclass="symbol">.</span><spanclass="method">index</span><spanclass="arrow">⇒</span><spanclass="returns">number</span><divclass="anchors"></div></div><divclass="body"><p>The index this <b>PopNode</b> is representing. For an implicit place-holder this is <codeclass="inline">0</code>.</p>
</div></div><aname="asm-linknode"></a><aname="asm-ast--nodes--asm-linknode"></a><h3class="show-anchors"><div>LinkNode<spanclass="inherits"> inherits <ahref="/v5/api/other/assembly/ast/#asm-valuenode">ValueNode</a></span><divclass="anchors"><aclass="self"href="/v5/api/other/assembly/ast/#asm-linknode"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/asm/src.ts/assembler.ts#L282">source</a></div></div></h3><p>A <b>LinkNode</b> represents a link to another <ahref="/v5/api/other/assembly/ast/#asm-node">Node</a>'s data, for example <codeclass="inline">$foo</code> or <codeclass="inline">#bar</code>.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">linkNode</span><spanclass="symbol">.</span><spanclass="method">label</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>The name of the target node.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">linkNode</span><spanclass="symbol">.</span><spanclass="method">type</span><spanclass="arrow">⇒</span><spanclass="returns">"offset" | "length"</span><divclass="anchors"></div></div><divclass="body"><p>Whether this node is for an offset or a length value of the target node.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">opcodeNode</span><spanclass="symbol">.</span><spanclass="method">opcode</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/other/assembly/api/#asm-opcode">Opcode</a></span><divclass="anchors"></div></div><divclass="body"><p>The opcode for this Node.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">opcodeNode</span><spanclass="symbol">.</span><spanclass="method">operands</span><spanclass="arrow">⇒</span><spanclass="returns">Array<<ahref="/v5/api/other/assembly/ast/#asm-valuenode">ValueNode</a>></span><divclass="anchors"></div></div><divclass="body"><p>A list of all operands passed into this Node.</p>
</div></div><aname="asm-evaluationnode"></a><aname="asm-ast--nodes--asm-evaluationnode"></a><h3class="show-anchors"><div>EvaluationNode<spanclass="inherits"> inherits <ahref="/v5/api/other/assembly/ast/#asm-valuenode">ValueNode</a></span><divclass="anchors"><aclass="self"href="/v5/api/other/assembly/ast/#asm-evaluationnode"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/asm/src.ts/assembler.ts#L517">source</a></div></div></h3><p>An <b>EvaluationNode</b> is used to execute code and insert the results but does not generate any output assembly, using the <codeclass="inline">{{! code here }}</code> syntax.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">literalNode</span><spanclass="symbol">.</span><spanclass="method">verbatim</span><spanclass="arrow">⇒</span><spanclass="returns">boolean</span><divclass="anchors"></div></div><divclass="body"><p>This is true in a <ahref="/v5/api/other/assembly/ast/#asm-datanode">DataNode</a> context, since in that case the value should be taken verbatim and no <codeclass="inline">PUSH</code> operation should be added, otherwise false.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">evaluationNode</span><spanclass="symbol">.</span><spanclass="method">script</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>The code to evaluate and produce the result to use as a literal.</p>
</div></div><aname="asm-executionnode"></a><aname="asm-ast--nodes--asm-executionnode"></a><h3class="show-anchors"><div>ExecutionNode<spanclass="inherits"> inherits <ahref="/v5/api/other/assembly/ast/#asm-node">Node</a></span><divclass="anchors"><aclass="self"href="/v5/api/other/assembly/ast/#asm-executionnode"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/asm/src.ts/assembler.ts#L546">source</a></div></div></h3><p>An <b>ExecutionNode</b> is used to execute code but does not generate any output assembly, using the <codeclass="inline">{{! code here }}</code> syntax.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">evaluationNode</span><spanclass="symbol">.</span><spanclass="method">script</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>The code to execute. Any result is ignored.</p>
</div></div><aname="asm-labellednode"></a><aname="asm-ast--nodes--asm-labellednode"></a><h3class="show-anchors"><div>LabelledNode<spanclass="inherits"> inherits <ahref="/v5/api/other/assembly/ast/#asm-node">Node</a></span><divclass="anchors"><aclass="self"href="/v5/api/other/assembly/ast/#asm-labellednode"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/asm/src.ts/assembler.ts#L418">source</a></div></div></h3><p>A <b>LabelledNode</b> is used for any Node that has a name, and can therefore be targeted by a <ahref="/v5/api/other/assembly/ast/#asm-linknode">LinkNode</a>.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">labelledNode</span><spanclass="symbol">.</span><spanclass="method">name</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>The name of this node.</p>
</div></div><aname="asm-labelnode"></a><aname="asm-ast--nodes--asm-labelnode"></a><h3class="show-anchors"><div>LabelNode<spanclass="inherits"> inherits <ahref="/v5/api/other/assembly/ast/#asm-labellednode">LabelledNode</a></span><divclass="anchors"><aclass="self"href="/v5/api/other/assembly/ast/#asm-labelnode"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/asm/src.ts/assembler.ts#L429">source</a></div></div></h3><p>A <b>LabelNode</b> is used as a place to <codeclass="inline">JUMP</code> to by referencing it name, using <codeclass="inline">@myLabel:</code>. A <codeclass="inline">JUMPDEST</code> is automatically inserted at the bytecode offset.</p>
<aname="asm-datanode"></a><aname="asm-ast--nodes--asm-datanode"></a><h3class="show-anchors"><div>DataNode<spanclass="inherits"> inherits <ahref="/v5/api/other/assembly/ast/#asm-labellednode">LabelledNode</a></span><divclass="anchors"><aclass="self"href="/v5/api/other/assembly/ast/#asm-datanode"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/asm/src.ts/assembler.ts#L465">source</a></div></div></h3><p>A <b>DataNode</b> allows for data to be inserted directly into the output assembly, using <codeclass="inline">@myData[ ... ]</code>. The data is padded if needed to ensure values that would otherwise be regarded as a <codeclass="inline">PUSH</code> value does not impact anything past the data.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">dataNode</span><spanclass="symbol">.</span><spanclass="method">data</span><spanclass="arrow">⇒</span><spanclass="returns">Array<<ahref="/v5/api/other/assembly/ast/#asm-valuenode">ValueNode</a>></span><divclass="anchors"></div></div><divclass="body"><p>The child nodes, which each represent a verbatim piece of data in insert.</p>
</div></div><aname="asm-scopenode"></a><aname="asm-ast--nodes--asm-scopenode"></a><h3class="show-anchors"><div>ScopeNode<spanclass="inherits"> inherits <ahref="/v5/api/other/assembly/ast/#asm-labellednode">LabelledNode</a></span><divclass="anchors"><aclass="self"href="/v5/api/other/assembly/ast/#asm-scopenode"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/asm/src.ts/assembler.ts#L565">source</a></div></div></h3><p>A <b>ScopeNode</b> allows a new frame of reference that all <ahref="/v5/api/other/assembly/ast/#asm-linknode">LinkNode</a>'s will use when resolving offset locations, using <codeclass="inline">@myScope{ ... }</code>.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">scopeNode</span><spanclass="symbol">.</span><spanclass="method">statements</span><spanclass="arrow">⇒</span><spanclass="returns">Array<<ahref="/v5/api/other/assembly/ast/#asm-node">Node</a>></span><divclass="anchors"></div></div><divclass="body"><p>The list of child nodes for this scope.</p>
<divclass="copyright">The content of this site is licensed under the <ahref="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on February 8, 2021, 3:25pm.</div>