<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="base ancestor show link depth-1"><ahref="/v5/api/">Application Programming Interface</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/signer/">Signers</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="ancestor show link depth-2"><ahref="/v5/api/utils/">Utilities</a></div><divclass="ancestor show link depth-3"><ahref="/v5/api/utils/abi/">Application Binary Interface</a></div><divclass="show link depth-4"><ahref="/v5/api/utils/abi/coder/">AbiCoder</a></div><divclass="show link depth-4"><ahref="/v5/api/utils/abi/formats/">ABI Formats</a></div><divclass="myself ancestor ancestor show link depth-4"><ahref="/v5/api/utils/abi/fragments/">Fragments</a></div><divclass="show link depth-4"><ahref="/v5/api/utils/abi/interface/">Interface</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/address/">Addresses</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/bignumber/">BigNumber</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/bytes/">Byte Manipulation</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/constants/">Constants</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/display-logic/">Display Logic and Input</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/encoding/">Encoding Utilities</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/fixednumber/">FixedNumber</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/hashing/">Hashing Algorithms</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/hdnode/">HD Wallet</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/logger/">Logging</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/properties/">Property Utilities</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/signing-key/">Signing Key</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/strings/">Strings</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/transactions/">Transactions</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/web/">Web Utilities</a></div><divclass="show link depth-3"><ahref="/v5/api/utils/wordlists/">Wordlists</a></div><divclass="show link depth-2"><ahref="/v5/api/other/">Other Libraries</a></div><divclass="hide link depth-3"><ahref="/v5/api/other/assembly/">Assembly</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/dialect/">Ethers ASM Dialect</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/api/">Utilities</a></div><divclass="hide link depth-4"><ahref="/v5/api/other/assembly/ast/">Abstract Syntax Tree</a></div><divclass="hide link depth-3"><ahref="/v5/api/other/hardware/">Hardware Wallets</a></div><divc
<aname="fragments"></a><aname="fragments"></a><h1class="show-anchors"><div>Fragments<divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#fragments"></a></div></div></h1><p>Explain an ABI.</p>
<aname="fragments--formats--json-string-abi-solidity-output-json"></a><h3class="show-anchors"><div>JSON String ABI (Solidity Output JSON)<divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#fragments--formats--json-string-abi-solidity-output-json"></a></div></div></h3><p>The <b>JSON ABI Format</b> is the format that is <ahref="https://solidity.readthedocs.io/en/v0.6.0/using-the-compiler.html#output-description">output from the Solidity compiler</a>.</p>
<p>A JSON serialized object is always a string, which represents an Array of Objects, where each Object has various properties describing the <ahref="/v5/api/utils/abi/fragments/#Fragment">Fragment</a> of the ABI.</p>
<p>The deserialied JSON string (which is a normal JavaScript Object) may also be passed into any function which accepts a JSON String ABI.</p>
<aname="fragments--formats--humanb-readable-abi"></a><h3class="show-anchors"><div>Humanb-Readable ABI<divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#fragments--formats--humanb-readable-abi"></a></div></div></h3><p>The Human-Readable ABI was</p>
<aname="fragments--output-formats"></a><aname="fragments--formats--fragments--output-formats"></a><h3class="show-anchors"><div>Output Formats<divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#fragments--output-formats"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/fragments.ts#L235">source</a></div></div></h3><p>Each <ahref="/v5/api/utils/abi/fragments/#Fragment">Fragment</a> and <ahref="/v5/api/utils/abi/fragments/#ParamType">ParamType</a> may be output using its <codeclass="inline">format</code> method.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">utils</span><spanclass="symbol">.</span><spanclass="path">FragmentTypes</span><spanclass="symbol">.</span><spanclass="method">full</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>This is a full human-readable string, including all parameter names, any optional modifiers (e.g. <codeclass="inline">indexed</code>, <codeclass="inline">public</code>, etc) and white-space to aid in human readabiliy.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">utils</span><spanclass="symbol">.</span><spanclass="path">FragmentTypes</span><spanclass="symbol">.</span><spanclass="method">minimal</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>This is similar to <codeclass="inline">full</code>, except with no unnecessary whitespace or parameter names. This is useful for storing a minimal string which can still fully reconstruct the original Fragment using <ahref="/v5/api/utils/abi/fragments/#Fragment-from">Fragment&thinsp;.&thinsp;from</a>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">utils</span><spanclass="symbol">.</span><spanclass="path">FragmentTypes</span><spanclass="symbol">.</span><spanclass="method">json</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>This returns a JavaScript Object which is safe to call <codeclass="inline">JSON.stringify</code> on to create a JSON string.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">utils</span><spanclass="symbol">.</span><spanclass="path">FragmentTypes</span><spanclass="symbol">.</span><spanclass="method">sighash</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>This is a minimal output format, which is used by Solidity when computing a signature hash or an event topic hash.</p>
</div></div><divclass="definition container-box warning"><divclass="term">Note</div><divclass="body"><p>The <codeclass="inline">sighash</code> format is <b>insufficient</b> to re-create the original <ahref="/v5/api/utils/abi/fragments/#Fragment">Fragment</a>, since it discards modifiers such as indexed, anonymous, stateMutability, etc.</p>
</div></div><aname="Fragment"></a><aname="fragments--Fragment"></a><h2class="show-anchors"><div>Fragment<divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#Fragment"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/fragments.ts#L405">source</a></div></div></h2><p>An ABI is a collection of <b>Fragments</b>, where each fragment specifies:</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">fragment</span><spanclass="symbol">.</span><spanclass="method">name</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>This is the name of the Event or Function. This will be null for a <ahref="/v5/api/utils/abi/fragments/#ConstructorFragment">ConstructorFragment</a>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fragment</span><spanclass="symbol">.</span><spanclass="method">type</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>This is a string which indicates the type of the <ahref="/v5/api/utils/abi/fragments/#Fragment">Fragment</a>. This will be one of:</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fragment</span><spanclass="symbol">.</span><spanclass="method">inputs</span><spanclass="arrow">⇒</span><spanclass="returns">Array<<ahref="/v5/api/utils/abi/fragments/#ParamType">ParamType</a>></span><divclass="anchors"></div></div><divclass="body"><p>This is an array of of each <ahref="/v5/api/utils/abi/fragments/#ParamType">ParamType</a> for the input parameters to the Constructor, Event of Function.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">fragment</span><spanclass="symbol">.</span><spanclass="method">gas</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/bignumber/">BigNumber</a></span><divclass="anchors"></div></div><divclass="body"><p>This is the gas limit that should be used during deployment. It may be null.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fragment</span><spanclass="symbol">.</span><spanclass="method">payable</span><spanclass="arrow">⇒</span><spanclass="returns">boolean</span><divclass="anchors"></div></div><divclass="body"><p>This is whether the constructor may receive ether during deployment as an endowment (i.e. msg.value != 0).</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fragment</span><spanclass="symbol">.</span><spanclass="method">stateMutability</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>This is the state mutability of the constructor. It can be any of:</p>
<aname="ConstructorFragment-from"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">utils</span><spanclass="symbol">.</span><spanclass="path">ConstructorFragment</span><spanclass="symbol">.</span><spanclass="method">from</span><spanclass="symbol">(</span><spanclass="param">objectOrString</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/abi/fragments/#ConstructorFragment">ConstructorFragment</a></span><divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#ConstructorFragment-from"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/fragments.ts#L746">source</a></div></div><divclass="body"><p>Tra la la...</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">fragment</span><spanclass="symbol">.</span><spanclass="method">anonymous</span><spanclass="arrow">⇒</span><spanclass="returns">boolean</span><divclass="anchors"></div></div><divclass="body"><p>This is whether the event is anonymous. An anonymous Event does not inject its topic hash as topic0 when creating a log.</p>
<aname="EventFragment-from"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">utils</span><spanclass="symbol">.</span><spanclass="path">EventFragment</span><spanclass="symbol">.</span><spanclass="method">from</span><spanclass="symbol">(</span><spanclass="param">objectOrString</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/abi/fragments/#EventFragment">EventFragment</a></span><divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#EventFragment-from"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/fragments.ts#L520">source</a></div></div><divclass="body"><p>Tra la la...</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">fragment</span><spanclass="symbol">.</span><spanclass="method">constant</span><spanclass="arrow">⇒</span><spanclass="returns">boolean</span><divclass="anchors"></div></div><divclass="body"><p>This is whether the function is constant (i.e. does not change state). This is true if the state mutability is <codeclass="inline">pure</code> or <codeclass="inline">view</code>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fragment</span><spanclass="symbol">.</span><spanclass="method">stateMutability</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"></div></div><divclass="body"><p>This is the state mutability of the constructor. It can be any of:</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">fragment</span><spanclass="symbol">.</span><spanclass="method">outputs</span><spanclass="arrow">⇒</span><spanclass="returns">Array<<ahref="/v5/api/utils/abi/fragments/#ParamType">ParamType</a>></span><divclass="anchors"></div></div><divclass="body"><p>A list of the Function output parameters.</p>
<aname="FunctionFragment-from"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">utils</span><spanclass="symbol">.</span><spanclass="path">FunctionFragment</span><spanclass="symbol">.</span><spanclass="method">from</span><spanclass="symbol">(</span><spanclass="param">objectOrString</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/abi/fragments/#FunctionFragment">FunctionFragment</a></span><divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#FunctionFragment-from"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/fragments.ts#L746">source</a></div></div><divclass="body"><p>Tra la la...</p>
</div></div><aname="ParamType"></a><aname="fragments--ParamType"></a><h2class="show-anchors"><div>ParamType<divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#ParamType"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/fragments.ts#L251">source</a></div></div></h2><p>The following examples will represent the Solidity parameter:</p>
<aname="ParamType-name"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">paramType</span><spanclass="symbol">.</span><spanclass="method">name</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#ParamType-name"></a></div></div><divclass="body"><p>The local parameter name. This may be null for unnamed parameters. For example, the parameter definition <codeclass="inline">string foobar</code> would be <codeclass="inline">foobar</code>.</p>
</div></div><aname="ParamType-type"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">paramType</span><spanclass="symbol">.</span><spanclass="method">type</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#ParamType-type"></a></div></div><divclass="body"><p>The full type of the parameter, including tuple and array symbols. This may be null for unnamed parameters. For the above example, this would be <codeclass="inline">foobar</code>.</p>
</div></div><aname="ParamType-baseType"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">paramType</span><spanclass="symbol">.</span><spanclass="method">baseType</span><spanclass="arrow">⇒</span><spanclass="returns">string</span><divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#ParamType-baseType"></a></div></div><divclass="body"><p>The base type of the parameter. For primitive types (e.g. <codeclass="inline">address</code>, <codeclass="inline">uint256</code>, etc) this is equal to <ahref="/v5/api/utils/abi/fragments/#ParamType-type">type</a>. For arrays, it will be the string <codeclass="inline">array</code> and for a tuple, it will be the string <codeclass="inline">tuple</code>.</p>
</div></div><aname="ParamType-indexed"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">paramType</span><spanclass="symbol">.</span><spanclass="method">indexed</span><spanclass="arrow">⇒</span><spanclass="returns">boolean</span><divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#ParamType-indexed"></a></div></div><divclass="body"><p>Whether the parameter has been marked as indexed. This <b>only</b> applies to parameters which are part of an <ahref="/v5/api/utils/abi/fragments/#EventFragment">EventFragment</a>.</p>
</div></div><aname="ParamType-arrayChildren"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">paramType</span><spanclass="symbol">.</span><spanclass="method">arrayChildren</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/abi/fragments/#ParamType">ParamType</a></span><divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#ParamType-arrayChildren"></a></div></div><divclass="body"><p>The type of children of the array. This is null for for any parameter wjhich is not an array.</p>
</div></div><aname="ParamType-arrayLength"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">paramType</span><spanclass="symbol">.</span><spanclass="method">arrayLength</span><spanclass="arrow">⇒</span><spanclass="returns">number</span><divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#ParamType-arrayLength"></a></div></div><divclass="body"><p>The length of the array, or <codeclass="inline">-1</code> for dynamic-length arrays. This is null for parameters which is not arrays.</p>
</div></div><aname="ParamType-components"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">paramType</span><spanclass="symbol">.</span><spanclass="method">components</span><spanclass="arrow">⇒</span><spanclass="returns">Array<<ahref="/v5/api/utils/abi/fragments/#ParamType">ParamType</a>></span><divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#ParamType-components"></a></div></div><divclass="body"><p>The components of a tuple. This is null for non-tuple parameters.</p>
</div></div><aname="fragments--ParamType--methods"></a><h3class="show-anchors"><div>Methods<divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#fragments--ParamType--methods"></a></div></div></h3><p>Tra la la...</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">paramType</span><spanclass="symbol">.</span><spanclass="method">format</span><spanclass="symbol">(</span><spanclass="symbol">[</span><spanclass="param">outputType</span> = <spanclass="param">sighash</span><spanclass="symbol">]</span><spanclass="symbol">)</span><divclass="anchors"></div></div><divclass="body"><p>Tra la la...</p>
</div></div><aname="ParamType-from"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">utils</span><spanclass="symbol">.</span><spanclass="path">ParamType</span><spanclass="symbol">.</span><spanclass="method">from</span><spanclass="symbol">(</span><spanclass="param">objectOrString</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/abi/fragments/#ParamType">ParamType</a></span><divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#ParamType-from"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/fragments.ts#L357">source</a></div></div><divclass="body"><p>Tra la la...</p>
</div></div><aname="ParamType-isParamType"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">utils</span><spanclass="symbol">.</span><spanclass="path">ParamType</span><spanclass="symbol">.</span><spanclass="method">isParamType</span><spanclass="symbol">(</span><spanclass="param">object</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">boolean</span><divclass="anchors"><aclass="self"href="/v5/api/utils/abi/fragments/#ParamType-isParamType"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/fragments.ts#L388">source</a></div></div><divclass="body"><p>Tra la la...</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>. Last modified on June 12, 2020, 7:17pm.</div>