ethers.js/docs/api/utils/abi/interface/index.html
2020-02-25 14:57:11 -05:00

58 lines
43 KiB
HTML

<html><head><title>Interface</title><link rel="stylesheet" type="text/css" href="/static/style.css"></head><body><div class="sidebar"><div class="header"><div class="logo"><a href="/"><div class="image"></div><div class="name">ethers</div><div class="version">v5.0-beta</div></a></div></div><div class="toc"><div><div class="link title"><a href="/">Documentation</a></div><div class="base show link depth-1"><a href="/getting-started/">Getting Started</a></div><div class="hide link depth-2"><a href="/getting-started/#getting-started--installing">Installing</a></div><div class="hide link depth-2"><a href="/getting-started/#getting-started--importing">Importing</a></div><div class="base show link depth-1"><a href="/concepts/">Concepts</a></div><div class="hide link depth-2"><a href="/concepts/events/">Events</a></div><div class="hide link depth-3"><a href="/concepts/events/#events--solidity-topics">Solidity Topics</a></div><div class="hide link depth-2"><a href="/concepts/gas/">Gas</a></div><div class="hide link depth-3"><a href="/concepts/gas/#gas-price">Gas Price</a></div><div class="hide link depth-3"><a href="/concepts/gas/#gas-limit">Gas Limit</a></div><div class="base ancestor show link depth-1"><a href="/api/">Application Programming Interface</a></div><div class="show link depth-2"><a href="/api/contract/">Contract Interaction</a></div><div class="hide link depth-3"><a href="/api/contract/contract/">Contract</a></div><div class="hide link depth-4"><a href="/api/contract/contract/#contract--properties">Properties</a></div><div class="hide link depth-4"><a href="/api/contract/contract/#contract--methods">Methods</a></div><div class="hide link depth-4"><a href="/api/contract/contract/#contract--events">Events</a></div><div class="hide link depth-4"><a href="/api/contract/contract/#contract-metaclass">Meta-Class</a></div><div class="hide link depth-3"><a href="/api/contract/example/">Example: ERC-20 Contract</a></div><div class="hide link depth-4"><a href="/api/contract/example/#example-erc-20-contract--connecting-to-a-contract">Connecting to a Contract</a></div><div class="hide link depth-4"><a href="/api/contract/example/#example-erc-20-contract--properties-inheritted-from-contract">Properties ^^//(inheritted from [[contract]])//^^</a></div><div class="hide link depth-4"><a href="/api/contract/example/#example-erc-20-contract--methods-inheritted-from-contract">Methods ^^//(inheritted from [[contract]])//^^</a></div><div class="hide link depth-4"><a href="/api/contract/example/#erc20-events">Events ^^//(inheritted from Contract)//^^</a></div><div class="hide link depth-4"><a href="/api/contract/example/#example-erc-20-contract--meta-class-methods-added-at-runtime">Meta-Class Methods ^^//(added at Runtime)//^^</a></div><div class="hide link depth-4"><a href="/api/contract/example/#example-erc-20-contract--meta-class-filters-added-at-runtime">Meta-Class Filters ^^//(added at Runtime)//^^</a></div><div class="show link depth-2"><a href="/api/signer/">Signers</a></div><div class="hide link depth-3"><a href="/api/signer/#signer">Signer</a></div><div class="hide link depth-3"><a href="/api/signer/#wallet">Wallet</a></div><div class="hide link depth-3"><a href="/api/signer/#void-signer">VoidSigner</a></div><div class="hide link depth-3"><a href="/api/signer/#externally-owned-account">ExternallyOwnedAccount</a></div><div class="show link depth-2"><a href="/api/providers/">Providers</a></div><div class="hide link depth-3"><a href="/api/providers/provider/">Provider</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#provider--accounts-methods">Accounts Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#provider--blocks-methods">Blocks Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#provider--ethereum-naming-service-ens-methods">Ethereum Naming Service (ENS) Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#provider--logs-methods">Logs Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#provider--network-status-methods">Network Status Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#provider--transactions-methods">Transactions Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#provider--event-emitter-methods">Event Emitter Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#provider--inspection-methods">Inspection Methods</a></div><div class="hide link depth-3"><a href="/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><div class="hide link depth-4"><a href="/api/providers/jsonrpc-provider/#signer-jsonrpc">JsonRpcSigner</a></div><div class="hide link depth-4"><a href="/api/providers/jsonrpc-provider/#provider-jsonrpc-uncheckedsigner">JsonRpcUncheckedSigner</a></div><div class="hide link depth-3"><a href="/api/providers/api-providers/">API Providers</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#api-providers--etherscanprovider">EtherscanProvider</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#api-providers--infuraprovider">InfuraProvider</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#api-providers--alchemyprovider">AlchemyProvider</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#api-providers--cloudfrontprovider">CloudfrontProvider</a></div><div class="hide link depth-3"><a href="/api/providers/other/">Other Providers</a></div><div class="hide link depth-4"><a href="/api/providers/other/#provider-fallback">FallbackProvider</a></div><div class="hide link depth-4"><a href="/api/providers/other/#provider-ipc">IpcProvider</a></div><div class="hide link depth-4"><a href="/api/providers/other/#provider-urljsonrpc">UrlJsonRpcProvider</a></div><div class="hide link depth-4"><a href="/api/providers/other/#provider-web3">Web3Provider</a></div><div class="hide link depth-3"><a href="/api/providers/types/">Types</a></div><div class="hide link depth-4"><a href="/api/providers/types/#provider-blocktag">BlockTag</a></div><div class="hide link depth-4"><a href="/api/providers/types/#provider-network">Network</a></div><div class="hide link depth-4"><a href="/api/providers/types/#provider-block">Block</a></div><div class="hide link depth-4"><a href="/api/providers/types/#types--events-and-logs">Events and Logs</a></div><div class="hide link depth-4"><a href="/api/providers/types/#types--transactions">Transactions</a></div><div class="ancestor show link depth-2"><a href="/api/utils/">Utilities</a></div><div class="ancestor show link depth-3"><a href="/api/utils/abi/">Application Binary Interface</a></div><div class="myself ancestor ancestor show link depth-4"><a href="/api/utils/abi/interface/">Interface</a></div><div class="child link depth-5"><a href="/api/utils/abi/interface/#abi-interface--creating-instances">Creating Instances</a></div><div class="child link depth-5"><a href="/api/utils/abi/interface/#abi-interface--properties">Properties</a></div><div class="child link depth-5"><a href="/api/utils/abi/interface/#abi-interface--formatting">Formatting</a></div><div class="child link depth-5"><a href="/api/utils/abi/interface/#abi-interface--fragment-access">Fragment Access</a></div><div class="child link depth-5"><a href="/api/utils/abi/interface/#abi-interface--signature-and-topic-hashes">Signature and Topic Hashes</a></div><div class="child link depth-5"><a href="/api/utils/abi/interface/#abi-interface--encoding-data">Encoding Data</a></div><div class="child link depth-5"><a href="/api/utils/abi/interface/#abi-interface--decoding-data">Decoding Data</a></div><div class="child link depth-5"><a href="/api/utils/abi/interface/#abi-interface--parsing">Parsing</a></div><div class="child link depth-5"><a href="/api/utils/abi/interface/#abi-interface--types">Types</a></div><div class="child link depth-5"><a href="/api/utils/abi/interface/#abi-fragmentid">Specifying Fragments</a></div><div class="show link depth-4"><a href="/api/utils/abi/fragments/">Fragments</a></div><div class="hide link depth-5"><a href="/api/utils/abi/fragments/#fragments--formats">Formats</a></div><div class="hide link depth-5"><a href="/api/utils/abi/fragments/#abi-fragment">Fragment</a></div><div class="hide link depth-5"><a href="/api/utils/abi/fragments/#abi-constructorfragment">ConstructorFragment</a></div><div class="hide link depth-5"><a href="/api/utils/abi/fragments/#abi-eventfragment">EventFragment</a></div><div class="hide link depth-5"><a href="/api/utils/abi/fragments/#abi-functionfragment">FunctionFragment</a></div><div class="hide link depth-5"><a href="/api/utils/abi/fragments/#abi-paramtype">ParamType</a></div><div class="show link depth-3"><a href="/api/utils/address/">Addresses</a></div><div class="hide link depth-4"><a href="/api/utils/address/#address-formats">Address Formats</a></div><div class="hide link depth-4"><a href="/api/utils/address/#addresses--functions">Functions</a></div><div class="show link depth-3"><a href="/api/utils/bignumber/">BigNumber</a></div><div class="hide link depth-4"><a href="/api/utils/bignumber/#bignumber--types">Types</a></div><div class="hide link depth-4"><a href="/api/utils/bignumber/#bignumber--creating-instances">Creating Instances</a></div><div class="hide link depth-4"><a href="/api/utils/bignumber/#bignumber--methods">Methods</a></div><div class="hide link depth-4"><a href="/api/utils/bignumber/#bignumber--notes">Notes</a></div><div class="show link depth-3"><a href="/api/utils/bytes/">Byte Manipulation</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#byte-manipulation--types">Types</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#byte-manipulation--inspection">Inspection</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#byte-manipulation--converting-between-arrays-and-hexstrings">Converting between Arrays and Hexstrings</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#byte-manipulation--array-manipulation">Array Manipulation</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#byte-manipulation--hexstring-manipulation">Hexstring Manipulation</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#byte-manipulation--signature-conversion">Signature Conversion</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#byte-manipulation--random-bytes">Random Bytes</a></div><div class="show link depth-3"><a href="/api/utils/constants/">Constants</a></div><div class="hide link depth-4"><a href="/api/utils/constants/#constants--bytes">Bytes</a></div><div class="hide link depth-4"><a href="/api/utils/constants/#constants--strings">Strings</a></div><div class="hide link depth-4"><a href="/api/utils/constants/#constants--bignumber">BigNumber</a></div><div class="show link depth-3"><a href="/api/utils/display-logic/">Display Logic and Input</a></div><div class="hide link depth-4"><a href="/api/utils/display-logic/#display-logic-and-input--units">Units</a></div><div class="hide link depth-4"><a href="/api/utils/display-logic/#display-logic-and-input--functions">Functions</a></div><div class="show link depth-3"><a href="/api/utils/encoding/">Encoding Utilities</a></div><div class="hide link depth-4"><a href="/api/utils/encoding/#bse58">Base58</a></div><div class="hide link depth-4"><a href="/api/utils/encoding/#base64">Base64</a></div><div class="hide link depth-4"><a href="/api/utils/encoding/#rlp">Recursive-Length Prefix</a></div><div class="show link depth-3"><a href="/api/utils/fixednumber/">FixedNumber</a></div><div class="hide link depth-4"><a href="/api/utils/fixednumber/#fixednumber--creating-instances">Creating Instances</a></div><div class="hide link depth-4"><a href="/api/utils/fixednumber/#fixednumber--properties">Properties</a></div><div class="hide link depth-4"><a href="/api/utils/fixednumber/#fixednumber--methods">Methods</a></div><div class="hide link depth-4"><a href="/api/utils/fixednumber/#fixedformat">FixedFormat</a></div><div class="show link depth-3"><a href="/api/utils/hashing/">Hashing Algorithms</a></div><div class="hide link depth-4"><a href="/api/utils/hashing/#hashing-algorithms--cryptographic-hashing">Cryptographic Hashing</a></div><div class="hide link depth-4"><a href="/api/utils/hashing/#hashing-algorithms--common-hashing-helpers">Common Hashing Helpers</a></div><div class="hide link depth-4"><a href="/api/utils/hashing/#hashing-algorithms--solidity-hashing-algorithms">Solidity Hashing Algorithms</a></div><div class="show link depth-3"><a href="/api/utils/hdnode/">HD Wallet</a></div><div class="hide link depth-4"><a href="/api/utils/hdnode/#hd-wallet--types">Types</a></div><div class="hide link depth-4"><a href="/api/utils/hdnode/#hdnode">HDNode</a></div><div class="hide link depth-4"><a href="/api/utils/hdnode/#hd-wallet--other-functions">Other Functions</a></div><div class="show link depth-3"><a href="/api/utils/logger/">Logging</a></div><div class="hide link depth-4"><a href="/api/utils/logger/#logger">Logger</a></div><div class="hide link depth-4"><a href="/api/utils/logger/#errors">Errors</a></div><div class="hide link depth-4"><a href="/api/utils/logger/#logger-levels">Log Levels</a></div><div class="show link depth-3"><a href="/api/utils/properties/">Property Utilities</a></div><div class="show link depth-3"><a href="/api/utils/signing-key/">Signing Key</a></div><div class="hide link depth-4"><a href="/api/utils/signing-key/#utils-signingkey--other-functions">Other Functions</a></div><div class="show link depth-3"><a href="/api/utils/strings/">Strings</a></div><div class="hide link depth-4"><a href="/api/utils/strings/#bytes32-string">Bytes32String</a></div><div class="hide link depth-4"><a href="/api/utils/strings/#utf8-string">UTF-8 Strings</a></div><div class="hide link depth-4"><a href="/api/utils/strings/#unicode-normalization-form">UnicodeNormalizationForm</a></div><div class="hide link depth-4"><a href="/api/utils/strings/#utf8error">Custom UTF-8 Error Handling</a></div><div class="show link depth-3"><a href="/api/utils/transactions/">Transactions</a></div><div class="hide link depth-4"><a href="/api/utils/transactions/#utils-transactions--types">Types</a></div><div class="hide link depth-4"><a href="/api/utils/transactions/#utils-transactions--functions">Functions</a></div><div class="show link depth-3"><a href="/api/utils/web/">Web Utilities</a></div><div class="show link depth-3"><a href="/api/utils/wordlists/">Wordlists</a></div><div class="hide link depth-4"><a href="/api/utils/wordlists/#wordlist">Wordlist</a></div><div class="hide link depth-4"><a href="/api/utils/wordlists/#wordlist-languages">Languages</a></div><div class="show link depth-2"><a href="/api/other/">Other Libraries</a></div><div class="hide link depth-3"><a href="/api/other/assembly/">Assembly</a></div><div class="hide link depth-4"><a href="/api/other/assembly/dialect/">Ethers ASM Dialect</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#asm-dialect-opcode">Opcodes</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#asm-dialect-label">Labels</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#asm-dialect-literal">Literals</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#asm-dialect-comment">Comments</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#asm-dialect-scope">Scopes</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#asm-dialect-datasegment">Data Segment</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#asm-dialect-links">Links</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#asm-dialect-placeholder">Stack Placeholders</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#asm-dialect-scripting">Evaluation and Excution</a></div><div class="hide link depth-4"><a href="/api/other/assembly/api/">Utilities</a></div><div class="hide link depth-5"><a href="/api/other/assembly/api/#asm-utilities--assembler">Assembler</a></div><div class="hide link depth-5"><a href="/api/other/assembly/api/#asm-utilities--disassembler">Disassembler</a></div><div class="hide link depth-5"><a href="/api/other/assembly/api/#asm-opcode">Opcode</a></div><div class="hide link depth-4"><a href="/api/other/assembly/ast/">Abstract Syntax Tree</a></div><div class="hide link depth-5"><a href="/api/other/assembly/ast/#asm-ast--types">Types</a></div><div class="hide link depth-5"><a href="/api/other/assembly/ast/#asm-ast--nodes">Nodes</a></div><div class="hide link depth-3"><a href="/api/other/hardware/">Hardware Wallets</a></div><div class="hide link depth-4"><a href="/api/other/hardware/#hw-ledger">LedgerSigner</a></div><div class="base show link depth-1"><a href="/cli/">Command Line Interfaces</a></div><div class="hide link depth-2"><a href="/cli/ethers/">Sandbox Utility</a></div><div class="hide link depth-3"><a href="/cli/ethers/#sandbox-utility--help">Help</a></div><div class="hide link depth-3"><a href="/cli/ethers/#sandbox-utility--examples">Examples</a></div><div class="hide link depth-2"><a href="/cli/asm/">Assembler</a></div><div class="hide link depth-3"><a href="/cli/asm/#cli-asm--help">Help</a></div><div class="hide link depth-3"><a href="/cli/asm/#cli-asm--example-input-files">Example Input Files</a></div><div class="hide link depth-3"><a href="/cli/asm/#cli-asm--assembler-examples">Assembler Examples</a></div><div class="hide link depth-3"><a href="/cli/asm/#cli-asm--disassembler-examples">Disassembler Examples</a></div><div class="hide link depth-2"><a href="/cli/ens/">Ethereum Naming Service</a></div><div class="hide link depth-3"><a href="/cli/ens/#ethereum-naming-service--help">Help</a></div><div class="hide link depth-3"><a href="/cli/ens/#ethereum-naming-service--examples">Examples</a></div><div class="hide link depth-2"><a href="/cli/typescript/">TypeScript</a></div><div class="hide link depth-3"><a href="/cli/typescript/#typescript--help">Help</a></div><div class="hide link depth-3"><a href="/cli/typescript/#typescript--examples">Examples</a></div><div class="hide link depth-2"><a href="/cli/plugin/">Making Your Own</a></div><div class="hide link depth-3"><a href="/cli/plugin/#cli-cli">CLI</a></div><div class="hide link depth-3"><a href="/cli/plugin/#cli-plugin">Plugin</a></div><div class="hide link depth-3"><a href="/cli/plugin/#cli-argparser">ArgParser</a></div><div class="base show link depth-1"><a href="/cookbook/">Cookbook</a></div><div class="base show link depth-1"><a href="/migration/">Migration Guide</a></div><div class="hide link depth-2"><a href="/migration/web3/">Migration: From Web3.js</a></div><div class="hide link depth-3"><a href="/migration/web3/#migration-from-web3-js--contracts">Contracts</a></div><div class="hide link depth-3"><a href="/migration/web3/#migration-from-web3-js--providers">Providers</a></div><div class="hide link depth-3"><a href="/migration/web3/#migration-from-web3-js--numbers">Numbers</a></div><div class="hide link depth-3"><a href="/migration/web3/#migration-from-web3-js--utilities">Utilities</a></div><div class="hide link depth-2"><a href="/migration/ethers-v4/">Migration: From Ethers v4</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#migration-v4--bignumber">BigNumber</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#migration-v4--contracts">Contracts</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#migration-v4--errors">Errors</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#migration-v4--interface">Interface</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#migration-v4--utilities">Utilities</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#migration-v4--wallet">Wallet</a></div><div class="base show link depth-1"><a href="/testing/">Testing</a></div><div class="base show link depth-1"><a href="/contributing/">Contributing and Hacking</a></div><div class="hide link depth-2"><a href="/contributing/#contributing-and-hacking--building">Building</a></div><div class="base show link depth-1"><a href="/documentation/">Flatworm Docs</a></div><div class="hide link depth-2"><a href="/documentation/#flatworm-fragments">Fragments</a></div><div class="hide link depth-2"><a href="/documentation/#flatworm-markdown">Markdown</a></div><div class="hide link depth-2"><a href="/documentation/#flatworm-config">Configuration</a></div><div class="hide link depth-2"><a href="/documentation/#flatworm-extended-directive-functions">Extended Directive Functions</a></div><div class="base show link depth-1"><a href="/license/">License and Copyright</a></div></div></div></div><div class="content"><div class="breadcrumbs"><a href="/">Documentation</a>&nbsp;&nbsp;&raquo;&nbsp;&nbsp;<a href="/api/">API</a>&nbsp;&nbsp;&raquo;&nbsp;&nbsp;<a href="/api/utils/">Utilities</a>&nbsp;&nbsp;&raquo;&nbsp;&nbsp;<a href="/api/utils/abi/">ABI</a>&nbsp;&nbsp;&raquo;&nbsp;&nbsp;<span class="current">Interface</span></div><a name="abi-interface"></a><a name="abi-interface"></a><a name="abi-interface"></a><h1 class="show-anchors"><div>Interface<div class="anchors"><a class="self" href="#abi-interface"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L46">source</a></div></div></h1>
<p>The <b>Interface</b> Class abstracts the encoding and decoding required to interact with contracts on the Ethereum network.</p><p>Many of the standards organically evolved along side the <a href="https://solidity.readthedocs.io/en/v0.6.2/">Solidity</a> language, which other languages have adopted to remain compatibile with existing deployed contracts.</p><p>The EVM itself does not understand what the ABI is. It is simply an agreed upon set of formats to encode various types of data which each contract can expect so they can interoperate with each other.</p>
<a name="abi-interface--creating-instances"></a><h2 class="show-anchors"><div>Creating Instances<div class="anchors"><a class="self" href="#abi-interface--creating-instances"></a></div></div></h2>
<div class="property show-anchors"><div class="signature"><span class="modifier">new </span><span class="path">ethers</span> . <span class="path">utils</span> . <span class="method">Interface</span> ( <span class="param">abi</span> ) <div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L60">source</a></div></div><div class="body"><p>Create a new <b>Interface</b> from a JSON string or object representing <i>abi</i>.</p><p>The <i>abi</i> may be a JSON string or the parsed Object (using JSON.parse) which is emitted by the <a href="https://solidity.readthedocs.io/en/v0.6.0/using-the-compiler.html#output-description">Solidity compiler</a> (or compatible languages).</p><p>The <i>abi</i> may also be a <a href="https://blog.ricmoo.com/human-readable-contract-abis-in-ethers-js-141902f4d917">Human-Readable Abi</a>, which is a format the Ethers created to simplify manually typing the ABI into the source and so that a Contract ABI can also be referenced easily within the same source file.</p></div></div>
<a name="abi-interface--properties"></a><h2 class="show-anchors"><div>Properties<div class="anchors"><a class="self" href="#abi-interface--properties"></a></div></div></h2>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">fragments</span> <span class="arrow">&rArr;</span> <span class="returns">Array&lt;&thinsp;<a href="/api/utils/abi/fragments/#abi-fragment">Fragment</a>&thinsp;&gt;</span><div class="anchors"></div></div><div class="body"><p>All the <a href="/api/utils/abi/fragments/#abi-fragment">Fragments</a> in the interface.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">events</span> <span class="arrow">&rArr;</span> <span class="returns">Array&lt;&thinsp;<a href="/api/utils/abi/fragments/#abi-eventfragment">EventFragment</a>&thinsp;&gt;</span><div class="anchors"></div></div><div class="body"><p>All the <a href="/api/utils/abi/fragments/#abi-eventfragment">Event Fragments</a> in the interface.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">functions</span> <span class="arrow">&rArr;</span> <span class="returns">Array&lt;&thinsp;<a href="/api/utils/abi/fragments/#abi-functionfragment">FunctionFragment</a>&thinsp;&gt;</span><div class="anchors"></div></div><div class="body"><p>All the <a href="/api/utils/abi/fragments/#abi-functionfragment">Function Fragments</a> in the interface.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">deploy</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/utils/abi/fragments/#abi-constructorfragment">ConstructorFragment</a></span><div class="anchors"></div></div><div class="body"><p>The <a href="/api/utils/abi/fragments/#abi-constructorfragment">Constructor Fragments</a> for the interface.</p></div></div>
<a name="abi-interface--formatting"></a><h2 class="show-anchors"><div>Formatting<div class="anchors"><a class="self" href="#abi-interface--formatting"></a></div></div></h2>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">format</span> ( [ <span class="param">format</span> ] ) <span class="arrow">&rArr;</span> <span class="returns">string&nbsp;&nbsp;|&nbsp;&nbsp;Array&lt;&thinsp;string&thinsp;&gt;</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L119">source</a></div></div><div class="body"><p>Return the formatted <b>Interface</b>. If the format type is <code class="inline">json</code> a single string is returned, otherwise an Array of the human-readable strings is returned.</p></div></div>
<a name="abi-interface--fragment-access"></a><h2 class="show-anchors"><div>Fragment Access<div class="anchors"><a class="self" href="#abi-interface--fragment-access"></a></div></div></h2>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">getFunction</span> ( <span class="param">fragment</span> ) <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/utils/abi/fragments/#abi-functionfragment">FunctionFragment</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L153">source</a></div></div><div class="body"><p>Returns the <a href="/api/utils/abi/fragments/#abi-functionfragment">FunctionFragment</a> for <i>fragment</i> (see <a href="/api/utils/abi/interface/#abi-fragmentid">Specifying Fragments</a>).</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">getEvent</span> ( <span class="param">fragment</span> ) <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/utils/abi/fragments/#abi-eventfragment">EventFragment</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L185">source</a></div></div><div class="body"><p>Returns the <a href="/api/utils/abi/fragments/#abi-eventfragment">EventFragment</a> for <i>fragment</i> (see <a href="/api/utils/abi/interface/#abi-fragmentid">Specifying Fragments</a>).</p></div></div>
<a name="abi-interface--signature-and-topic-hashes"></a><h2 class="show-anchors"><div>Signature and Topic Hashes<div class="anchors"><a class="self" href="#abi-interface--signature-and-topic-hashes"></a></div></div></h2>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">getSighash</span> ( <span class="param">fragment</span> ) <span class="arrow">&rArr;</span> <span class="returns">string&lt;&thinsp;<a href="/api/utils/bytes/#datahexstring">DataHexstring</a>&lt;&thinsp;4&thinsp;&gt;&thinsp;&gt;</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L218">source</a></div></div><div class="body"><p>Return the sighash (or Function Selector) for <i>fragment</i> (see <a href="/api/utils/abi/interface/#abi-fragmentid">Specifying Fragments</a>).</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">getEventTopic</span> ( <span class="param">fragment</span> ) <span class="arrow">&rArr;</span> <span class="returns">string&lt;&thinsp;<a href="/api/utils/bytes/#datahexstring">DataHexstring</a>&lt;&thinsp;32&thinsp;&gt;&thinsp;&gt;</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L227">source</a></div></div><div class="body"><p>Return the topic hash for <i>fragment</i> (see <a href="/api/utils/abi/interface/#abi-fragmentid">Specifying Fragments</a>).</p></div></div>
<a name="abi-interface--encoding-data"></a><h2 class="show-anchors"><div>Encoding Data<div class="anchors"><a class="self" href="#abi-interface--encoding-data"></a></div></div></h2>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">encodeDeploy</span> ( [ <span class="param">values</span> ] ) <span class="arrow">&rArr;</span> <span class="returns">string&lt;&thinsp;<a href="/api/utils/bytes/#datahexstring">DataHexstring</a>&thinsp;&gt;</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L244">source</a></div></div><div class="body"><p>Return the encoded deployment data, which can be concatenated to the deployment bytecode of a contract to pass <i>values</i> into the contract constructor.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">encodeFilterTopics</span> ( <span class="param">fragment</span> [ , <span class="param">values</span> ] ) <span class="arrow">&rArr;</span> <span class="returns">Array&lt;&thinsp;topic&nbsp;&nbsp;|&nbsp;&nbsp;Array&lt;&thinsp;topic&thinsp;&gt;&thinsp;&gt;</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L318">source</a></div></div><div class="body"><p>Returns the encoded topic filter, which can be passed to getLogs for <i>fragment</i> (see <a href="/api/utils/abi/interface/#abi-fragmentid">Specifying Fragments</a>) for the given <i>values</i>.</p><p>Each <i>topic</i> is a 32 byte (64 nibble) <a href="/api/utils/bytes/#datahexstring">DataHexstring</a>.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">encodeFunctionData</span> ( <span class="param">fragment</span> [ , <span class="param">values</span> ] ) <span class="arrow">&rArr;</span> <span class="returns">string&lt;&thinsp;<a href="/api/utils/bytes/#datahexstring">DataHexstring</a>&thinsp;&gt;</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L264">source</a></div></div><div class="body"><p>Returns the encoded data, which can be used as the data for a transaction for <i>fragment</i> (see <a href="/api/utils/abi/interface/#abi-fragmentid">Specifying Fragments</a>) for the given <i>values</i>.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">encodeFunctionResult</span> ( <span class="param">fragment</span> [ , <span class="param">values</span> ] ) <span class="arrow">&rArr;</span> <span class="returns">string&lt;&thinsp;<a href="/api/utils/bytes/#datahexstring">DataHexstring</a>&thinsp;&gt;</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L309">source</a></div></div><div class="body"><p>Returns the encoded result, which would normally be the response from a call for <i>fragment</i> (see <a href="/api/utils/abi/interface/#abi-fragmentid">Specifying Fragments</a>) for the given <i>values</i>.</p><p>Most developers will not need this method, but may be useful for authors of a mock blockchain.</p></div></div>
<a name="abi-interface--decoding-data"></a><h2 class="show-anchors"><div>Decoding Data<div class="anchors"><a class="self" href="#abi-interface--decoding-data"></a></div></div></h2>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">decodeEventLog</span> ( <span class="param">fragment</span> , <span class="param">data</span> [ , <span class="param">topics</span> ] ) <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/utils/abi/interface/#abi-result">Result</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L368">source</a></div></div><div class="body"><p>Returns the decoded event values from an event log for <i>fragment</i> (see <a href="/api/utils/abi/interface/#abi-fragmentid">Specifying Fragments</a>) for the given <i>data</i> with the optional <i>topics</i>.</p><p>If <i>topics</i> is not specified, placeholders will be inserted into the result.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">decodeFunctionData</span> ( <span class="param">fragment</span> , <span class="param">data</span> ) <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/utils/abi/interface/#abi-result">Result</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L249">source</a></div></div><div class="body"><p>Returns the decoded values from transaction data for <i>fragment</i> (see <a href="/api/utils/abi/interface/#abi-fragmentid">Specifying Fragments</a>) for the given <i>data</i>.</p><p>Most developers will not need this method, but may be useful for debugging or inspecting transactions.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">decodeFunctionResult</span> ( <span class="param">fragment</span> , <span class="param">data</span> ) <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/utils/abi/interface/#abi-result">Result</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L276">source</a></div></div><div class="body"><p>Returns the decoded values from the result of a call for <i>fragment</i> (see <a href="/api/utils/abi/interface/#abi-fragmentid">Specifying Fragments</a>) for the given <i>data</i>.</p></div></div>
<a name="abi-interface--parsing"></a><h2 class="show-anchors"><div>Parsing<div class="anchors"><a class="self" href="#abi-interface--parsing"></a></div></div></h2>
<p>The functions are generally the most useful for most developers. They will automatically search the ABI for a matching Event or Function and decode the components as a fully specified description.</p>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">parseLog</span> ( <span class="param">log</span> ) <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/utils/abi/interface/#abi-log">LogDescription</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L444">source</a></div></div><div class="body"><p>Search the event that matches the <i>log</i> topic hash and parse the values the log represents.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">interface</span> . <span class="method">parseTransaction</span> ( <span class="param">transaction</span> ) <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/utils/abi/interface/#abi-transaction">TransactionDescription</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abi/src.ts/interface.ts#L427">source</a></div></div><div class="body"><p>Search for the function that matches the <i>transaction</i> data sighash and parse the transaction properties.</p></div></div>
<a name="abi-interface--types"></a><h2 class="show-anchors"><div>Types<div class="anchors"><a class="self" href="#abi-interface--types"></a></div></div></h2>
<a name="abi-result"></a><a name="abi-interface--types--abi-result"></a><a name="abi-result"></a><h3 class="show-anchors"><div>Result<span class="inherits"> inherits Array&lt;any&gt;</span><div class="anchors"><a class="self" href="#abi-result"></a></div></div></h3>
<p>A <b>Result</b> is an array, so each value can be accessed as a positional argument.</p><p>Additionally, if values are named, the identical object as its positional value can be accessed by its name.</p><p>The name <code class="inline">length</code> is however reserved as it is part of the Array, so any named value for this key is renamed to <code class="inline">_length</code>. If there is a name collision, only the first is available by its key.</p>
<a name="abi-log"></a><a name="abi-interface--types--abi-log"></a><a name="abi-log"></a><h3 class="show-anchors"><div>LogDescription<div class="anchors"><a class="self" href="#abi-log"></a></div></div></h3>
<div class="property show-anchors"><div class="signature"><span class="path">logDescription</span> . <span class="method">args</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/utils/abi/interface/#abi-result">Result</a></span><div class="anchors"></div></div><div class="body"><p>The values of the input parameters of the event.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">logDescription</span> . <span class="method">eventFragment</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/utils/abi/fragments/#abi-eventfragment">EventFragment</a></span><div class="anchors"></div></div><div class="body"><p>The <a href="/api/utils/abi/fragments/#abi-eventfragment">EventFragment</a> which matches the topic in the Log.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">logDescription</span> . <span class="method">name</span> <span class="arrow">&rArr;</span> <span class="returns">string</span><div class="anchors"></div></div><div class="body"><p>The event name. (e.g. <code class="inline">Transfer</code>)</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">logDescription</span> . <span class="method">signature</span> <span class="arrow">&rArr;</span> <span class="returns">string</span><div class="anchors"></div></div><div class="body"><p>The event signature. (e.g. <code class="inline">Transfer(address,address,uint256)</code>)</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">logDescription</span> . <span class="method">topic</span> <span class="arrow">&rArr;</span> <span class="returns">string</span><div class="anchors"></div></div><div class="body"><p>The topic hash.</p></div></div>
<a name="abi-transaction"></a><a name="abi-interface--types--abi-transaction"></a><a name="abi-transaction"></a><h3 class="show-anchors"><div>TransactionDescription<div class="anchors"><a class="self" href="#abi-transaction"></a></div></div></h3>
<div class="property show-anchors"><div class="signature"><span class="path">transactionDescription</span> . <span class="method">args</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/utils/abi/interface/#abi-result">Result</a></span><div class="anchors"></div></div><div class="body"><p>The decoded values from the transaction data which were passed as the input parameters.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">transactionDescription</span> . <span class="method">functionFragment</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/utils/abi/fragments/#abi-functionfragment">FunctionFragment</a></span><div class="anchors"></div></div><div class="body"><p>The <a href="/api/utils/abi/fragments/#abi-functionfragment">FunctionFragment</a> which matches the sighash in the transaction data.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">transactionDescription</span> . <span class="method">name</span> <span class="arrow">&rArr;</span> <span class="returns">string</span><div class="anchors"></div></div><div class="body"><p>The name of the function. (e.g. <code class="inline">transfer</code>)</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">transactionDescription</span> . <span class="method">sighash</span> <span class="arrow">&rArr;</span> <span class="returns">string</span><div class="anchors"></div></div><div class="body"><p>The sighash (or function selector) that matched the transaction data.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">transactionDescription</span> . <span class="method">signature</span> <span class="arrow">&rArr;</span> <span class="returns">string</span><div class="anchors"></div></div><div class="body"><p>The signature of the function. (e.g. <code class="inline">transfer(address,uint256)</code>)</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">transactionDescription</span> . <span class="method">value</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/utils/bignumber/">BigNumber</a></span><div class="anchors"></div></div><div class="body"><p>The value from the transaction.</p></div></div>
<a name="abi-fragmentid"></a><a name="abi-interface--abi-fragmentid"></a><a name="abi-fragmentid"></a><h2 class="show-anchors"><div>Specifying Fragments<div class="anchors"><a class="self" href="#abi-fragmentid"></a></div></div></h2>
<p>When specifying a fragment to any of the functions in an <b>Interface</b>, any of the following may be used:</p><ul><li>The name of the event or function, if it is unique and non-ambiguous within the ABI (e.g. <code class="inline">transfer</code>)</li><li>The signature of the event or function. The signature is normalized, so, for example, <code class="inline">uint</code> and <code class="inline">uint256</code> are equivalent (e.g. <code class="inline">transfer(address, uint)</code>)</li><li>The sighash or topichash of the function. The sighash is often referred to the function selector in Solidity (e.g. <code class="inline">0xa9059cbb</code>)</li><li>A <a href="/api/utils/abi/fragments/#abi-fragment">Fragment</a></li></ul><div class="footer"><div class="nav previous"><a href="/api/utils/abi/"><span class="arrow">&larr;</span>Application Binary Interface</a></div> <div class="nav next"><a href="/api/utils/abi/fragments/">Fragments<span class="arrow">&rarr;</span></a></div></div><div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons Attribution 4.0 International License</a>.</div></div><script src="/script.js" type="text/javascript"></script></body></html><!-- ContentHash:0214075148b67e7a1eb883809077921aa17de4e29e344ba0c3fc36f86db19138 -->