<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="myself ancestor ancestor 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="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"><a
<aname="signers"></a><aname="signers"></a><h1class="show-anchors"><div>Signers<divclass="anchors"><aclass="self"href="/v5/api/signer/#signers"></a></div></div></h1><p>A <b>Signer</b> in <i>ethers</i> is an abstraction of an Ethereum Account, which can be used to sign messages and transactions and send signed transactions to the Ethereum Network to execute state changing operations.</p>
<p>For example, a Signer from MetaMask can send transactions and sign messages but cannot sign a transaction (without broadcasting it).</p>
<p>The most common Signers you will encounter are:</p>
<p><ul><li><ahref="/v5/api/signer/#Wallet">Wallet</a>, which is a class which knows its private key and can execute any operations with it </li><li><ahref="/v5/api/providers/jsonrpc-provider/#JsonRpcSigner">JsonRpcSigner</a>, which is connected to a <ahref="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a> (or sub-class) and is acquired using <ahref="/v5/api/providers/jsonrpc-provider/#JsonRpcProvider-getSigner">getSigner</a></li></ul></p>
<aname="Signer"></a><aname="signers--Signer"></a><h2class="show-anchors"><div>Signer<divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-signer/src.ts/index.ts#L58">source</a></div></div></h2><p>The <b>Signer</b> class is abstract and cannot be directly instantiated.</p>
<p>Instead use one of the concrete sub-classes, such as the <ahref="/v5/api/signer/#Wallet">Wallet</a>, <ahref="/v5/api/signer/#VoidSigner">VoidSigner</a> or <ahref="/v5/api/providers/jsonrpc-provider/#JsonRpcSigner">JsonRpcSigner</a>.</p>
<aname="Signer-connect"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">connect</span><spanclass="symbol">(</span><spanclass="param">provider</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/signer/#Signer">Signer</a></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-connect"></a></div></div><divclass="body"><p>Sub-classes <b>must</b> implement this, however they may simply throw an error if changing providers is not supported.</p>
</div></div><aname="Signer-getaddress"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">getAddress</span><spanclass="symbol">(</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< string<<ahref="/v5/api/utils/address/#address">Address</a>>></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-getaddress"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-signer/src.ts/index.ts#L81">source</a></div></div><divclass="body"><p>Returns a Promise that resolves to the account address.</p>
</div></div><aname="Signer-isSigner"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">Signer</span><spanclass="symbol">.</span><spanclass="method">isSigner</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/signer/#Signer-isSigner"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-signer/src.ts/index.ts#L238">source</a></div></div><divclass="body"><p>Returns true if an only if <i>object</i> is a <b>Signer</b>.</p>
<aname="Signer-getBalance"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">getBalance</span><spanclass="symbol">(</span><spanclass="symbol">[</span><spanclass="param">blockTag</span> = "<spanclass="param">latest</span>" <spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/utils/bignumber/">BigNumber</a>></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-getBalance"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-signer/src.ts/index.ts#L97">source</a></div></div><divclass="body"><p>Returns the balance of this wallet at <i>blockTag</i>.</p>
</div></div><aname="Signer-getChainId"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">getChainId</span><spanclass="symbol">(</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< number ></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-getChainId"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-signer/src.ts/index.ts#L131">source</a></div></div><divclass="body"><p>Returns the chain ID this wallet is connected to.</p>
</div></div><aname="Signer-getGasPrice"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">getGasPrice</span><spanclass="symbol">(</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/utils/bignumber/">BigNumber</a>></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-getGasPrice"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-signer/src.ts/index.ts#L137">source</a></div></div><divclass="body"><p>Returns the current gas price.</p>
</div></div><aname="Signer-getTransactionCount"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">getTransactionCount</span><spanclass="symbol">(</span><spanclass="symbol">[</span><spanclass="param">blockTag</span> = "<spanclass="param">latest</span>" <spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< number ></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-getTransactionCount"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-signer/src.ts/index.ts#L102">source</a></div></div><divclass="body"><p>Returns the number of transactions this account has ever sent. This is the value required to be included in transactions as the <codeclass="inline">nonce</code>.</p>
</div></div><aname="Signer-call"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">call</span><spanclass="symbol">(</span><spanclass="param">transactionRequest</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< string<<ahref="/v5/api/utils/bytes/#DataHexString">DataHexString</a>>></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-call"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-signer/src.ts/index.ts#L115">source</a></div></div><divclass="body"><p>Returns the result of calling using the <i>transactionRequest</i>, with this account address being used as the <codeclass="inline">from</code> field.</p>
</div></div><aname="Signer-estimateGas"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">estimateGas</span><spanclass="symbol">(</span><spanclass="param">transactionRequest</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/utils/bignumber/">BigNumber</a>></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-estimateGas"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-signer/src.ts/index.ts#L108">source</a></div></div><divclass="body"><p>Returns the result of estimating the cost to send the <i>transactionRequest</i>, with this account address being used as the <codeclass="inline">from</code> field.</p>
</div></div><aname="Signer-resolveName"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">resolveName</span><spanclass="symbol">(</span><spanclass="param">ensName</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< string<<ahref="/v5/api/utils/address/#address">Address</a>>></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-resolveName"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-signer/src.ts/index.ts#L142">source</a></div></div><divclass="body"><p>Returns the address associated with the <i>ensName</i>.</p>
<aname="Signer-signMessage"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">signMessage</span><spanclass="symbol">(</span><spanclass="param">message</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< string<<ahref="/v5/api/utils/bytes/#signature-raw">RawSignature</a>>></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-signMessage"></a></div></div><divclass="body"><p>This returns a Promise which resolves to the <ahref="/v5/api/utils/bytes/#signature-raw">Raw Signature</a> of <i>message</i>.</p>
<p>Sub-classes <b>must</b> implement this, however they may throw if signing a message is not supported, such as in a Contract-based Wallet or Meta-Transaction-based Wallet.</p>
</div></div><divclass="definition container-box note"><divclass="term">Note</div><divclass="body"><p>If <i>message</i> is a string, it is <b>treated as a string</b> and converted to its representation in UTF8 bytes.</p>
<p><b>If and only if</b> a message is a <ahref="/v5/api/utils/bytes/#Bytes">Bytes</a> will it be treated as binary data.</p>
<p>For example, the string <codeclass="inline">"0x1234"</code> is 6 characters long (and in this case 6 bytes long). This is <b>not</b> equivalent to the array <codeclass="inline">[ 0x12, 0x34 ]</code>, which is 2 bytes long.</p>
<p>A common case is to sign a hash. In this case, if the hash is a string, it <b>must</b> be converted to an array first, using the <ahref="/v5/api/utils/bytes/#utils-arrayify">arrayify</a> utility function.</p>
</div></div>
<aname="Signer-signTransaction"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">signTransaction</span><spanclass="symbol">(</span><spanclass="param">transactionRequest</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< string<<ahref="/v5/api/utils/bytes/#DataHexString">DataHexString</a>>></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-signTransaction"></a></div></div><divclass="body"><p>Returns a Promise which resolves to the signed transaction of the <i>transactionRequest</i>. This method does not populate any missing fields.</p>
<p>Sub-classes <b>must</b> implement this, however they may throw if signing a transaction is not supported, which is common for security reasons in many clients.</p>
</div></div><aname="Signer-sendTransaction"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">sendTransaction</span><spanclass="symbol">(</span><spanclass="param">transactionRequest</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/providers/types/#providers-TransactionResponse">TransactionResponse</a>></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-sendTransaction"></a></div></div><divclass="body"><p>This method populates the transactionRequest with missing fields, using <ahref="/v5/api/signer/#Signer-populateTransaction">populateTransaction</a> and returns a Promise which resolves to the transaction.</p>
<p>Sub-classes <b>must</b> implement this, however they may throw if sending a transaction is not supported, such as the <ahref="/v5/api/signer/#VoidSigner">VoidSigner</a> or if the Wallet is offline and not connected to a <ahref="/v5/api/providers/provider/">Provider</a>.</p>
</div></div><aname="Signer-signTypedData"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">_signTypedData</span><spanclass="symbol">(</span><spanclass="param">domain</span><spanclass="symbol">,</span><spanclass="param">types</span><spanclass="symbol">,</span><spanclass="param">value</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< string<<ahref="/v5/api/utils/bytes/#signature-raw">RawSignature</a>>></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-signTypedData"></a></div></div><divclass="body"><p>Signs the typed data <i>value</i> with <i>types</i> data structure for <i>domain</i> using the <ahref="https://eips.ethereum.org/EIPS/eip-712">EIP-712</a> specification.</p>
</div></div><divclass="definition container-box warning"><divclass="term">Experimental feature (this method name will change)</div><divclass="body"><p>This is still an experimental feature. If using it, please specify the <b>exact</b> version of ethers you are using (e.g. spcify <codeclass="inline">"5.0.18"</code>, <b>not</b><codeclass="inline">"^5.0.18"</code>) as the method name will be renamed from <codeclass="inline">_signTypedData</code> to <codeclass="inline">signTypedData</code> once it has been used in the field a bit.</p>
</div></div><divclass="code-title"><div>Typed Data Example</div></div><divclass="code"><spanclass="comment">// All properties on a domain are optional
</span></div><aname="Signer--subclassing"></a><aname="signers--Signer--Signer--subclassing"></a><h3class="show-anchors"><div>Sub-Classes<divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer--subclassing"></a></div></div></h3><p>It is very important that all important properties of a <b>Signer</b> are <b>immutable</b>. Since Ethereum is very asynchronous and deals with critical data (such as ether and other potentially valuable crypto assets), keeping properties such as the <i>provider</i> and <i>address</i> static throughout the life-cycle of the Signer helps prevent serious issues and many other classes and libraries make this assumption.</p>
<aname="Signer-checkTransaction"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">checkTransaction</span><spanclass="symbol">(</span><spanclass="param">transactionRequest</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/providers/types/#providers-TransactionRequest">TransactionRequest</a></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-checkTransaction"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-signer/src.ts/index.ts#L159">source</a></div></div><divclass="body"><p>This is generally not required to be overridden, but may be needed to provide custom behaviour in sub-classes.</p>
<p>This should return a <b>copy</b> of the <i>transactionRequest</i>, with any properties needed by <codeclass="inline">call</code>, <codeclass="inline">estimateGas</code> and <codeclass="inline">populateTransaction</code> (which is used by sendTransaction). It should also throw an error if any unknown key is specified.</p>
<p>The default implementation checks only if valid <ahref="/v5/api/providers/types/#providers-TransactionRequest">TransactionRequest</a> properties exist and adds <codeclass="inline">from</code> to the transaction if it does not exist.</p>
</div></div><aname="Signer-populateTransaction"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">signer</span><spanclass="symbol">.</span><spanclass="method">populateTransaction</span><spanclass="symbol">(</span><spanclass="param">transactionRequest</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/providers/types/#providers-TransactionRequest">TransactionRequest</a>></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Signer-populateTransaction"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-signer/src.ts/index.ts#L190">source</a></div></div><divclass="body"><p>This is generally not required to be overridden, but may be needed to provide custom behaviour in sub-classes.</p>
<p>This should return a <b>copy</b> of <i>transactionRequest</i>, follow the same procedure as <codeclass="inline">checkTransaction</code> and fill in any properties required for sending a transaction. The result should have all promises resolved; if needed the <ahref="/v5/api/utils/properties/#utils-resolveproperties">resolveProperties</a> utility function can be used for this.</p>
<p>The default implementation calls <codeclass="inline">checkTransaction</code> and resolves to if it is an ENS name, adds <codeclass="inline">gasPrice</code>, <codeclass="inline">nonce</code>, <codeclass="inline">gasLimit</code> and <codeclass="inline">chainId</code> based on the related operations on Signer.</p>
</div></div><aname="Wallet"></a><aname="signers--Wallet"></a><h2class="show-anchors"><div>Wallet<spanclass="inherits"> inherits <ahref="/v5/api/signer/#ExternallyOwnedAccount">ExternallyOwnedAccount</a> and <ahref="/v5/api/signer/#Signer">Signer</a></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Wallet"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/wallet/src.ts/index.ts#L30">source</a></div></div></h2><p>The Wallet class inherits <ahref="/v5/api/signer/#Signer">Signer</a> and can sign transactions and messages using a private key as a standard Externally Owned Account (EOA).</p>
<aname="Wallet-constructor"></a><divclass="property show-anchors"><divclass="signature"><spanclass="modifier">new </span><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="method">Wallet</span><spanclass="symbol">(</span><spanclass="param">privateKey</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">provider</span><spanclass="symbol">]</span><spanclass="symbol">)</span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Wallet-constructor"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/wallet/src.ts/index.ts#L40">source</a></div></div><divclass="body"><p>Create a new Wallet instance for <i>privateKey</i> and optionally connected to the <i>provider</i>.</p>
</div></div><aname="Wallet-createRandom"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">Wallet</span><spanclass="symbol">.</span><spanclass="method">createRandom</span><spanclass="symbol">(</span><spanclass="symbol">[</span><spanclass="param">options</span> = {} <spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/signer/#Wallet">Wallet</a></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Wallet-createRandom"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/wallet/src.ts/index.ts#L169">source</a></div></div><divclass="body"><p>Returns a new Wallet with a random private key, generated from cryptographically secure entropy sources. If the current environment does not have a secure entropy source, an error is thrown.</p>
</div></div><aname="Wallet-fromEncryptedJson"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">Wallet</span><spanclass="symbol">.</span><spanclass="method">fromEncryptedJson</span><spanclass="symbol">(</span><spanclass="param">json</span><spanclass="symbol">,</span><spanclass="param">password</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">progress</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise<<ahref="/v5/api/signer/#Wallet">Wallet</a>></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Wallet-fromEncryptedJson"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/wallet/src.ts/index.ts#L182">source</a></div></div><divclass="body"><p>Create an instance from an encrypted JSON wallet.</p>
</div></div><aname="Wallet-fromEncryptedJsonSync"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">Wallet</span><spanclass="symbol">.</span><spanclass="method">fromEncryptedJsonSync</span><spanclass="symbol">(</span><spanclass="param">json</span><spanclass="symbol">,</span><spanclass="param">password</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/signer/#Wallet">Wallet</a></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Wallet-fromEncryptedJsonSync"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/wallet/src.ts/index.ts#L188">source</a></div></div><divclass="body"><p>Create an instance from an encrypted JSON wallet.</p>
<p>This operation will operate synchronously which will lock up the user interface, possibly for a non-trivial duration. Most applications should use the asynchronous <codeclass="inline">fromEncryptedJson</code> instead.</p>
</div></div><aname="Wallet.fromMnemonic"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="path">Wallet</span><spanclass="symbol">.</span><spanclass="method">fromMnemonic</span><spanclass="symbol">(</span><spanclass="param">mnemonic</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">path</span><spanclass="symbol">,</span><spanclass="symbol">[</span><spanclass="param">wordlist</span><spanclass="symbol">]</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/signer/#Wallet">Wallet</a></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Wallet.fromMnemonic"></a></div></div><divclass="body"><p>Create an instance from a mnemonic phrase.</p>
<p>If path is not specified, the Ethereum default path is used (i.e. <codeclass="inline">m/44'/60'/0'/0/0</code>).</p>
<p>If wordlist is not specified, the English Wordlist is used.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">wallet</span><spanclass="symbol">.</span><spanclass="method">address</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 for the account this Wallet represents.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">wallet</span><spanclass="symbol">.</span><spanclass="method">provider</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/providers/provider/">Provider</a></span><divclass="anchors"></div></div><divclass="body"><p>The provider this wallet is connected to, which will be used for any <ahref="/v5/api/signer/#Signer--blockchain-methods">Blockchain Methods</a> methods. This can be null.</p>
</div></div><divclass="definition container-box note"><divclass="term">Note</div><divclass="body"><p>A <b>Wallet</b> instance is immutable, so if you wish to change the Provider, you may use the <ahref="/v5/api/signer/#Signer-connect">connect</a> method to create a new instance connected to the desired provider.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">wallet</span><spanclass="symbol">.</span><spanclass="method">publicKey</span><spanclass="arrow">⇒</span><spanclass="returns">string<<ahref="/v5/api/utils/bytes/#DataHexString">DataHexString</a>< 65 >></span><divclass="anchors"></div></div><divclass="body"><p>The uncompressed public key for this Wallet represents.</p>
<aname="Wallet-encrypt"></a><divclass="property show-anchors"><divclass="signature"><spanclass="path">wallet</span><spanclass="symbol">.</span><spanclass="method">encrypt</span><spanclass="symbol">(</span><spanclass="param">password</span><spanclass="symbol">,</span><spanclass="symbol">[</span><spanclass="param">options</span> = {} <spanclass="symbol">,</span><spanclass="symbol">[</span><spanclass="param">progress</span><spanclass="symbol">]</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns">Promise< string ></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#Wallet-encrypt"></a></div></div><divclass="body"><p>Encrypt the wallet using <i>password</i> returning a Promise which resolves to a JSON wallet.</p>
</div></div><divclass="code-title"><div>Wallet Examples</div></div><divclass="code"><spanclass="comment">// Create a wallet instance from a mnemonic...
</span>mnemonic = "announce room limb pattern dry unit scale effort smooth jazz weasel alcohol"
</div><aname="VoidSigner"></a><aname="signers--VoidSigner"></a><h2class="show-anchors"><div>VoidSigner<spanclass="inherits"> inherits <ahref="/v5/api/signer/#Signer">Signer</a></span><divclass="anchors"><aclass="self"href="/v5/api/signer/#VoidSigner"></a><aclass="source"href="https://github.com/ethers-io/ethers.js/blob/master/packages/abstract-signer/src.ts/index.ts#L243">source</a></div></div></h2><p>A <b>VoidSigner</b> is a simple Signer which cannot sign.</p>
<p>It is useful as a read-only signer, when an API requires a Signer as a parameter, but it is known only read-only operations will be carried.</p>
<p>For example, the <codeclass="inline">call</code> operation will automatically have the provided address passed along during the execution.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="modifier">new </span><spanclass="path">ethers</span><spanclass="symbol">.</span><spanclass="method">VoidSigner</span><spanclass="symbol">(</span><spanclass="param">address</span><spanclass="symbol">[</span><spanclass="symbol">,</span><spanclass="param">provider</span><spanclass="symbol">]</span><spanclass="symbol">)</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/signer/#VoidSigner">VoidSigner</a></span><divclass="anchors"></div></div><divclass="body"><p>Create a new instance of a <b>VoidSigner</b> for <i>address</i>.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">voidSigner</span><spanclass="symbol">.</span><spanclass="method">address</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 of this <b>VoidSigner</b>.</p>
</span></div><aname="ExternallyOwnedAccount"></a><aname="signers--ExternallyOwnedAccount"></a><h2class="show-anchors"><div>ExternallyOwnedAccount<divclass="anchors"><aclass="self"href="/v5/api/signer/#ExternallyOwnedAccount"></a></div></div></h2><p>This is an interface which contains a minimal set of properties required for Externally Owned Accounts which can have certain operations performed, such as encoding as a JSON wallet.</p>
<divclass="property show-anchors"><divclass="signature"><spanclass="path">eoa</span><spanclass="symbol">.</span><spanclass="method">address</span><spanclass="arrow">⇒</span><spanclass="returns">string<<ahref="/v5/api/utils/address/#address">Address</a>></span><divclass="anchors"></div></div><divclass="body"><p>The <ahref="/v5/api/utils/address/#address">Address</a> of this EOA.</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">eoa</span><spanclass="symbol">.</span><spanclass="method">privateKey</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 privateKey of this EOA</p>
</div></div><divclass="property show-anchors"><divclass="signature"><spanclass="path">eoa</span><spanclass="symbol">.</span><spanclass="method">mnemonic</span><spanclass="arrow">⇒</span><spanclass="returns"><ahref="/v5/api/utils/hdnode/#Mnemonic">Mnemonic</a></span><divclass="anchors"></div></div><divclass="body"><p><i>Optional</i>. The account HD mnemonic, if it has one and can be determined. Some sources do not encode the mnemonic, such as HD extended keys.</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 November 22, 2020, 11:5pm.</div>