<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="show 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="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="myself ancestor ancestor 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><divclass="sho
<aname="UnsignedTransaction"></a><aname="transactions--transactions--types--UnsignedTransaction"></a><h3class="show-anchors"><div>UnsignedTransaction<divclass="anchors"><aclass="self"href="/v5/api/utils/transactions/#UnsignedTransaction"></a></div></div></h3><p>An unsigned transaction represents a transaction that has not been signed and its values are flexible as long as they are not ambiguous.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">unsignedTransaction</span><spanclass="symbol">.</span><spanclass="method">to</span><spanclass="arrow">⇒</span><spanclass="returns">string<<ahref="/v5/api/utils/address/#address">Address</a>></span><divclass="anchors"></div></div><divclass="body"><p>The addres this transaction is to.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">unsignedTransaction</span><spanclass="symbol">.</span><spanclass="method">nonce</span><spanclass="arrow">⇒</span><spanclass="returns">number</span><divclass="anchors"></div></div><divclass="body"><p>The nonce of this transaction.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">unsignedTransaction</span><spanclass="symbol">.</span><spanclass="method">gasLimit</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/bignumber/#BigNumberish">BigNumberish</a></span><divclass="anchors"></div></div><divclass="body"><p>The gas limit for this transaction.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">unsignedTransaction</span><spanclass="symbol">.</span><spanclass="method">gasPrice</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/bignumber/#BigNumberish">BigNumberish</a></span><divclass="anchors"></div></div><divclass="body"><p>The gas price for this transaction.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">unsignedTransaction</span><spanclass="symbol">.</span><spanclass="method">data</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/bytes/#BytesLike">BytesLike</a></span><divclass="anchors"></div></div><divclass="body"><p>The data for this transaction.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">unsignedTransaction</span><spanclass="symbol">.</span><spanclass="method">value</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/bignumber/#BigNumberish">BigNumberish</a></span><divclass="anchors"></div></div><divclass="body"><p>The value (in wei) for this transaction.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">unsignedTransaction</span><spanclass="symbol">.</span><spanclass="method">chainId</span><spanclass="arrow">⇒</span><spanclass="returns">number</span><divclass="anchors"></div></div><divclass="body"><p>The chain ID for this transaction. If the chain ID is 0 or null, then <ahref="https://eips.ethereum.org/EIPS/eip-155">EIP-155</a> is disabled and legacy signing is used, unless overridden in a signature.</p>
</div></div><aname="Transaction"></a><aname="transactions--transactions--types--Transaction"></a><h3class="show-anchors"><div>Transaction<divclass="anchors"><aclass="self"href="/v5/api/utils/transactions/#Transaction"></a></div></div></h3><p>A generic object to represent a transaction.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">transaction</span><spanclass="symbol">.</span><spanclass="method">hash</span><spanclass="arrow">⇒</span><spanclass="returns">string<<ahref="/v5/api/utils/bytes/#DataHexString">DataHexString</a>< 32 >></span><divclass="anchors"></div></div><divclass="body"><p>The transaction hash, which can be used as an identifier for <i>transaction</i>. This is the keccak256 of the serialized RLP encoded representation of <i>transaction</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">unsignedTransaction</span><spanclass="symbol">.</span><spanclass="method">to</span><spanclass="arrow">⇒</span><spanclass="returns">string<<ahref="/v5/api/utils/address/#address">Address</a>></span><divclass="anchors"></div></div><divclass="body"><p>The address <i>transaction</i> is to.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">transaction</span><spanclass="symbol">.</span><spanclass="method">from</span><spanclass="arrow">⇒</span><spanclass="returns">string<<ahref="/v5/api/utils/address/#address">Address</a>></span><divclass="anchors"></div></div><divclass="body"><p>The address <i>transaction</i> is from.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">transaction</span><spanclass="symbol">.</span><spanclass="method">nonce</span><spanclass="arrow">⇒</span><spanclass="returns">number</span><divclass="anchors"></div></div><divclass="body"><p>The nonce for <i>transaction</i>. Each transaction sent to the network from an account includes this, which ensures the order and non-replayability of a transaction. This must be equal to the current number of transactions ever sent to the network by the <b>from</b> address.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">transaction</span><spanclass="symbol">.</span><spanclass="method">gasLimit</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/bignumber/">BigNumber</a></span><divclass="anchors"></div></div><divclass="body"><p>The gas limit for <i>transaction</i>. An account must have enough ether to cover the gas (at the specified <b>gasPrice</b>). Any unused gas is refunded at the end of the transaction, and if there is insufficient gas to complete execution, the effects of the trasaction are reverted, but the gas is <b>fully consumed</b> and an out-of-gas error occurs.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">transaction</span><spanclass="symbol">.</span><spanclass="method">gasPrice</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/bignumber/">BigNumber</a></span><divclass="anchors"></div></div><divclass="body"><p>The price (in wei) per unit of gas for <i>transaction</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">transaction</span><spanclass="symbol">.</span><spanclass="method">data</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/bytes/#BytesLike">BytesLike</a></span><divclass="anchors"></div></div><divclass="body"><p>The data for <i>transaction</i>. In a contract this is the call data.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">transaction</span><spanclass="symbol">.</span><spanclass="method">value</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/bignumber/">BigNumber</a></span><divclass="anchors"></div></div><divclass="body"><p>The value (in wei) for <i>transaction</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">transaction</span><spanclass="symbol">.</span><spanclass="method">chainId</span><spanclass="arrow">⇒</span><spanclass="returns">number</span><divclass="anchors"></div></div><divclass="body"><p>The chain ID for <i>transaction</i>. This is used as part of <ahref="https://eips.ethereum.org/EIPS/eip-155">EIP-155</a> to prevent replay attacks on different networks.</p>
<p>For example, if a transaction was made on ropsten with an account also used on homestead, it would be possible for a transaction signed on ropsten to be executed on homestead, which is likely unintended.</p>
<p>There are situations where replay may be desired, however these are very rare and it is almost always recommended to specify the chain ID.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">transaction</span><spanclass="symbol">.</span><spanclass="method">r</span><spanclass="arrow">⇒</span><spanclass="returns">string<<ahref="/v5/api/utils/bytes/#DataHexString">DataHexString</a>< 32 >></span><divclass="anchors"></div></div><divclass="body"><p>The r portion of the elliptic curve signatures for <i>transaction</i>. This is more accurately, the x coordinate of the point r (from which the y can be computed, along with v).</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">transaction</span><spanclass="symbol">.</span><spanclass="method">s</span><spanclass="arrow">⇒</span><spanclass="returns">string<<ahref="/v5/api/utils/bytes/#DataHexString">DataHexString</a>< 32 >></span><divclass="anchors"></div></div><divclass="body"><p>The s portion of the elliptic curve signatures for <i>transaction</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">transaction</span><spanclass="symbol">.</span><spanclass="method">v</span><spanclass="arrow">⇒</span><spanclass="returns">number</span><divclass="anchors"></div></div><divclass="body"><p>The v portion of the elliptic curve signatures for <i>transaction</i>. This is used to refine which of the two possible points a given x-coordinate can have, and in <ahref="https://eips.ethereum.org/EIPS/eip-155">EIP-155</a> is additionally used to encode the chain ID into the serialized transaction.</p>
<aname="utils-parseTransaction"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">utils</span><spanclass="symbol">.</span><spanclass="method">parseTransaction</span><spanclass="symbol">(</span><spanclass="param">aBytesLike</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/transactions/#Transaction">Transaction</a></span><divclass="anchors"><aclass="self"href="/v5/api/utils/transactions/#utils-parseTransaction"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/transactions/src.ts/index.ts#L165">source</a></div></div><divclass="body"><p>Parses the transaction properties from a serialized transactions.</p>
</div></div><aname="utils-serializeTransaction"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">utils</span><spanclass="symbol">.</span><spanclass="method">serializeTransaction</span><spanclass="symbol">(</span><spanclass="param">tx</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">signature</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">string<<ahref="/v5/api/utils/bytes/#DataHexString">DataHexString</a>></span><divclass="anchors"><aclass="self"href="/v5/api/utils/transactions/#utils-serializeTransaction"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/transactions/src.ts/index.ts#L85">source</a></div></div><divclass="body"><p>Computes the serialized <i>transaction</i>, optionally serialized with the a <i>signature</i>. If <i>signature</i> is not present, the unsigned serialized transaction is returned, which can be used to compute the hash necessary to sign.</p>
<p>This function uses <ahref="https://eips.ethereum.org/EIPS/eip-155">EIP-155</a> if a chainId is provided, otherwise legacy serialization is used. It is <b>highly</b> recommended to always specify a <i>chainId</i>.</p>
<p>If <i>signature</i> includes a chain ID (explicitly or implicitly by using an <ahref="https://eips.ethereum.org/EIPS/eip-155">EIP-155</a><codeclass="inline">v</code> or <codeclass="inline">_vs</code>) it will be used to compute the chain ID.</p>
<p>If there is a mismatch between the chain ID of <i>transaction</i> and <i>signature</i> an error is thrown.</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>