ethers.js/docs/api/signer/index.html
2020-02-17 17:56:50 -05:00

53 lines
41 KiB
HTML

<html><head><title>Signer</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/#installing">Installing</a></div><div class="hide link depth-2"><a href="/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/#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/">Contracts</a></div><div class="hide link depth-3"><a href="/api/contract/#buckets">Buckets</a></div><div class="myself ancestor ancestor show link depth-2"><a href="/api/signer/">Signers</a></div><div class="child link depth-3"><a href="/api/signer/#signer">Signer</a></div><div class="child link depth-3"><a href="/api/signer/#wallet">Wallet</a></div><div class="child link depth-3"><a href="/api/signer/#voidsigner">VoidSigner</a></div><div class="child link depth-3"><a href="/api/signer/#externallyownedaccount">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/#accounts-methods">Accounts Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#blocks-methods">Blocks Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#ethereum-naming-service-(ens)-methods">Ethereum Naming Service (ENS) Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#logs-methods">Logs Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#network-status-methods">Network Status Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#transactions-methods">Transactions Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#event-emitter-methods">Event Emitter Methods</a></div><div class="hide link depth-4"><a href="/api/providers/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/#jsonrpcsigner">JsonRpcSigner</a></div><div class="hide link depth-4"><a href="/api/providers/jsonrpc-provider/#jsonrpcuncheckedsigner">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/#etherscanprovider">EtherscanProvider</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#infuraprovider">InfuraProvider</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#alchemyprovider">AlchemyProvider</a></div><div class="hide link depth-4"><a href="/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/#fallbackprovider">FallbackProvider</a></div><div class="hide link depth-4"><a href="/api/providers/other/#ipcprovider">IpcProvider</a></div><div class="hide link depth-4"><a href="/api/providers/other/#urljsonrpcprovider">UrlJsonRpcProvider</a></div><div class="hide link depth-4"><a href="/api/providers/other/#web3provider">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/#network">Network</a></div><div class="hide link depth-4"><a href="/api/providers/types/#block">Block</a></div><div class="hide link depth-4"><a href="/api/providers/types/#events-and-logs">Events and Logs</a></div><div class="hide link depth-4"><a href="/api/providers/types/#transactions">Transactions</a></div><div class="show link depth-2"><a href="/api/utils/">Utilities</a></div><div class="hide link depth-3"><a href="/api/utils/abi/">Application Binary Interface</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#formats">Formats</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#interface">Interface</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#fragment">Fragment</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#constructorfragment">ConstructorFragment</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#eventfragment">EventFragment</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#functionfragment">FunctionFragment</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#paramtype">ParamType</a></div><div class="hide 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/#functions">Functions</a></div><div class="hide link depth-3"><a href="/api/utils/bignumber/">BigNumber</a></div><div class="hide link depth-4"><a href="/api/utils/bignumber/#types">Types</a></div><div class="hide link depth-4"><a href="/api/utils/bignumber/#creating-instances">Creating Instances</a></div><div class="hide link depth-4"><a href="/api/utils/bignumber/#methods">Methods</a></div><div class="hide link depth-4"><a href="/api/utils/bignumber/#notes">Notes</a></div><div class="hide link depth-3"><a href="/api/utils/bytes/">Byte Manipulation</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#types">Types</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#inspection">Inspection</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#converting-between-arrays-and-hexstrings">Converting between Arrays and Hexstrings</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#array-manipulation">Array Manipulation</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#hexstring-manipulation">Hexstring Manipulation</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#signature-conversion">Signature Conversion</a></div><div class="hide link depth-4"><a href="/api/utils/bytes/#random-bytes">Random Bytes</a></div><div class="hide link depth-3"><a href="/api/utils/constants/">Constants</a></div><div class="hide link depth-4"><a href="/api/utils/constants/#bytes">Bytes</a></div><div class="hide link depth-4"><a href="/api/utils/constants/#strings">Strings</a></div><div class="hide link depth-4"><a href="/api/utils/constants/#bignumber">BigNumber</a></div><div class="hide 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/#units">Units</a></div><div class="hide link depth-4"><a href="/api/utils/display-logic/#functions">Functions</a></div><div class="hide link depth-3"><a href="/api/utils/encoding/">Encoding Utilities</a></div><div class="hide link depth-4"><a href="/api/utils/encoding/#base58">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/#recursive-length-prefix">Recursive-Length Prefix</a></div><div class="hide link depth-3"><a href="/api/utils/fixednumber/">FixedNumber</a></div><div class="hide link depth-4"><a href="/api/utils/fixednumber/#creating-instances">Creating Instances</a></div><div class="hide link depth-4"><a href="/api/utils/fixednumber/#properties">Properties</a></div><div class="hide link depth-4"><a href="/api/utils/fixednumber/#methods">Methods</a></div><div class="hide link depth-4"><a href="/api/utils/fixednumber/#fixedformat">FixedFormat</a></div><div class="hide link depth-3"><a href="/api/utils/hashing/">Hashing Algorithms</a></div><div class="hide link depth-4"><a href="/api/utils/hashing/#cryptographic-hashing">Cryptographic Hashing</a></div><div class="hide link depth-4"><a href="/api/utils/hashing/#common-hashing-helpers">Common Hashing Helpers</a></div><div class="hide link depth-4"><a href="/api/utils/hashing/#solidity-hashing-algorithms">Solidity Hashing Algorithms</a></div><div class="hide link depth-3"><a href="/api/utils/hdnode/">HD Wallet</a></div><div class="hide link depth-4"><a href="/api/utils/hdnode/#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/#other-functions">Other Functions</a></div><div class="hide link depth-3"><a href="/api/utils/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/#creating-instances">Creating instances</a></div><div class="hide link depth-3"><a href="/api/utils/properties/">Property Utilities</a></div><div class="hide 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/#other-functions">Other Functions</a></div><div class="hide link depth-3"><a href="/api/utils/strings/">Strings</a></div><div class="hide link depth-4"><a href="/api/utils/strings/#bytes32string">Bytes32String</a></div><div class="hide link depth-4"><a href="/api/utils/strings/#utf-8-strings">UTF-8 Strings</a></div><div class="hide link depth-4"><a href="/api/utils/strings/#unicodenormalizationform">UnicodeNormalizationForm</a></div><div class="hide link depth-4"><a href="/api/utils/strings/#custom-utf-8-error-handling">Custom UTF-8 Error Handling</a></div><div class="hide link depth-3"><a href="/api/utils/transactions/">Transactions</a></div><div class="hide link depth-4"><a href="/api/utils/transactions/#types">Types</a></div><div class="hide link depth-4"><a href="/api/utils/transactions/#functions">Functions</a></div><div class="hide link depth-3"><a href="/api/utils/web/">Web Utilities</a></div><div class="hide 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/#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/#opcodes">Opcodes</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#labels">Labels</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#literals">Literals</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#comments">Comments</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#scopes">Scopes</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#data-segment">Data Segment</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#links">Links</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#stack-placeholders">Stack Placeholders</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#evaluation-and-excution">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/#assembler">Assembler</a></div><div class="hide link depth-5"><a href="/api/other/assembly/api/#disassembler">Disassembler</a></div><div class="hide link depth-5"><a href="/api/other/assembly/api/#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/#types">Types</a></div><div class="hide link depth-5"><a href="/api/other/assembly/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/#ledgersigner">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/#help">Help</a></div><div class="hide link depth-3"><a href="/cli/ethers/#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/#help">Help</a></div><div class="hide link depth-3"><a href="/cli/asm/#example-input-files">Example Input Files</a></div><div class="hide link depth-3"><a href="/cli/asm/#assembler-examples">Assembler Examples</a></div><div class="hide link depth-3"><a href="/cli/asm/#disassembler-examples">Disassembler Examples</a></div><div class="hide link depth-2"><a href="/cli/ens/">ENS</a></div><div class="hide link depth-3"><a href="/cli/ens/#help">Help</a></div><div class="hide link depth-3"><a href="/cli/ens/#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/#help">Help</a></div><div class="hide link depth-3"><a href="/cli/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</a></div><div class="hide link depth-3"><a href="/cli/plugin/#plugin">Plugin</a></div><div class="hide link depth-3"><a href="/cli/plugin/#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/#contracts">Contracts</a></div><div class="hide link depth-3"><a href="/migration/web3/#providers">Providers</a></div><div class="hide link depth-3"><a href="/migration/web3/#numbers">Numbers</a></div><div class="hide link depth-3"><a href="/migration/web3/#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/#bignumber">BigNumber</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#contracts">Contracts</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#errors">Errors</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#interface">Interface</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#utilities">Utilities</a></div><div class="hide link depth-3"><a href="/migration/ethers-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/#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/#fragments">Fragments</a></div><div class="hide link depth-2"><a href="/documentation/#markdown">Markdown</a></div><div class="hide link depth-2"><a href="/documentation/#configuration">Configuration</a></div><div class="hide link depth-2"><a href="/documentation/#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/">Application Programming Interface</a>&nbsp;&nbsp;&raquo;&nbsp;&nbsp;<span class="current">Signer</span></div>
<a name="signers"></a><h1 class="show-anchors"><div>Signers<div class="anchors"><a class="self" href="#signers"></a></div></div></h1>
<p>A Signer represents...</p>
<a name="signer"></a><a name="signer"></a><h2 class="show-anchors"><div>Signer<div class="anchors"><a class="self" href="#signer"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-signer/src.ts/index.ts#L30">source</a></div></div></h2>
<p>The <b>Signer</b> class is abstract and cannot be directly instaniated. Instead use one of the concreate sub-classes, such as the <a href="/api/signer/#wallet">Wallet</a>, <a href="/api/signer/#void-signer">VoidSigner</a> or <a href="/api/providers/jsonrpc-provider/#signer-jsonrpc">JsonRpcSigner</a>.</p>
<a name="signer-connect"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">connect</span> ( <span class="param">provider</span> ) <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/signer/#signer">Signer</a></span><div class="anchors"><a class="self" href="#signer-connect"></a></div></div><div class="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>
<a name="signer-getaddress"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">getAddress</span> ( ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;string&lt;&thinsp;<a href="/api/utils/address/#address">Address</a>&thinsp;&gt;&thinsp;&gt;</span><div class="anchors"><a class="self" href="#signer-getaddress"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-signer/src.ts/index.ts#L53">source</a></div></div><div class="body"><p>Returns a Promise that resolves to the account address.</p><p>This is a Promise so that a <b>Signer</b> can be designed around an asynchronous source, such as hardware wallets.</p><p>Sub-classes <b>must</b> implement this.</p></div></div>
<a name="signer-issigner"></a><div class="property show-anchors"><div class="signature"><span class="path">Signer</span> . <span class="method">isSigner</span> ( <span class="param">object</span> ) <span class="arrow">&rArr;</span> <span class="returns">boolean</span><div class="anchors"><a class="self" href="#signer-issigner"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-signer/src.ts/index.ts#L205">source</a></div></div><div class="body"><p>Returns true if an only if <i>object</i> is a <b>Signer</b>.</p></div></div>
<a name="signer-blockchain"></a><a name="blockchain-methods"></a><h3 class="show-anchors"><div>Blockchain Methods<div class="anchors"><a class="self" href="#signer-blockchain"></a></div></div></h3>
<a name="signer-getbalance"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">getBalance</span> ( [ <span class="param">blockTag</span> = <span class="default-value">"</span><span class="param">latest</span>" ] ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;<a href="/api/utils/bignumber/">BigNumber</a>&thinsp;&gt;</span><div class="anchors"><a class="self" href="#signer-getbalance"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-signer/src.ts/index.ts#L69">source</a></div></div><div class="body"><p>Returns the balance of this wallet at <i>blockTag</i>.</p></div></div>
<a name="signer-getchainid"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">getChainId</span> ( ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;number&thinsp;&gt;</span><div class="anchors"><a class="self" href="#signer-getchainid"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-signer/src.ts/index.ts#L105">source</a></div></div><div class="body"><p>Returns ths chain ID this wallet is connected to.</p></div></div>
<a name="signer-getgasprice"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">getGasPrice</span> ( ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;<a href="/api/utils/bignumber/">BigNumber</a>&thinsp;&gt;</span><div class="anchors"><a class="self" href="#signer-getgasprice"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-signer/src.ts/index.ts#L110">source</a></div></div><div class="body"><p>Returns the current gas price.</p></div></div>
<a name="signer-gettransactioncount"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">getTransactionCount</span> ( [ <span class="param">blockTag</span> = <span class="default-value">"</span><span class="param">latest</span>" ] ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;number&thinsp;&gt;</span><div class="anchors"><a class="self" href="#signer-gettransactioncount"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-signer/src.ts/index.ts#L74">source</a></div></div><div class="body"><p>Returns the number of transactions this account has ever sent. This is the value required to be included in transactions as the <code class="inline">nonce</code>.</p></div></div>
<a name="signer-call"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">call</span> ( <span class="param">transactionRequest</span> ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;string&lt;&thinsp;<a href="/api/utils/bytes/#datahexstring">DataHexstring</a>&thinsp;&gt;&thinsp;&gt;</span><div class="anchors"><a class="self" href="#signer-call"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-signer/src.ts/index.ts#L88">source</a></div></div><div class="body"><p>Returns the result of calling using the <i>transactionRequest</i>, with this account address being used as the <code class="inline">from</code> field.</p></div></div>
<a name="signer-estimategas"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">estimateGas</span> ( <span class="param">transactionRequest</span> ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;<a href="/api/utils/bignumber/">BigNumber</a>&thinsp;&gt;</span><div class="anchors"><a class="self" href="#signer-estimategas"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-signer/src.ts/index.ts#L80">source</a></div></div><div class="body"><p>Returns the result of estimating the cost to send the <i>transactionRequest</i>, with this account address being used as the <code class="inline">from</code> field.</p></div></div>
<a name="signer-resolvename"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">resolveName</span> ( <span class="param">ensName</span> ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;string&lt;&thinsp;<a href="/api/utils/address/#address">Address</a>&thinsp;&gt;&thinsp;&gt;</span><div class="anchors"><a class="self" href="#signer-resolvename"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-signer/src.ts/index.ts#L115">source</a></div></div><div class="body"><p>Returns the address associated with the <i>ensName</i>.</p></div></div>
<a name="signing"></a><h3 class="show-anchors"><div>Signing<div class="anchors"><a class="self" href="#signing"></a></div></div></h3>
<a name="signer-signmessage"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">signMessage</span> ( <span class="param">message</span> ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;string&lt;&thinsp;<a href="/api/utils/bytes/#signature-flat">FlatSignature</a>&thinsp;&gt;&thinsp;&gt;</span><div class="anchors"><a class="self" href="#signer-signmessage"></a></div></div><div class="body"><p>This returns a Promise which resolves to the <a href="/api/utils/bytes/#signature-flat">Flat-Format 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.</p></div></div>
<div class="definition container-box note show-anchors"><div class="term">Note</div><div class="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 <a href="/api/utils/bytes/#bytes">Bytes</a> will it be treated as binary data.</p><p>For example, the string <code class="inline">"0x1234"</code> is 6 characters long (and in this case 6 bytes long). This is <b>not</b> equivalent to the array <code class="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 <a href="/api/utils/bytes/#utils-arrayify">arrayify</a> utility function.</p></div></div>
<a name="signer-signtransaction"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">signTransaction</span> ( <span class="param">transactionRequest</span> ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;string&lt;&thinsp;<a href="/api/utils/bytes/#datahexstring">DataHexstring</a>&thinsp;&gt;&thinsp;&gt;</span><div class="anchors"><a class="self" href="#signer-signtransaction"></a></div></div><div class="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.</p></div></div>
<a name="signer-sendtransaction"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">sendTransaction</span> ( <span class="param">transactionRequest</span> ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;<a href="/api/providers/types/#provider-transactionresponse">TransactionResponse</a>&thinsp;&gt;</span><div class="anchors"><a class="self" href="#signer-sendtransaction"></a></div></div><div class="body"><p>This method populates the transactionRequest with missing fields, using <a href="/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 signing a transaction is not supported.</p></div></div>
<a name="signer-subclassing"></a><a name="sub-classes"></a><h3 class="show-anchors"><div>Sub-Classes<div class="anchors"><a class="self" href="#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 helps prevent serious issues.</p><p>A sub-class <b>must</b> call <code class="inline">super()</code>.</p>
<a name="signer-checktransaction"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">checkTransaction</span> ( <span class="param">transactionRequest</span> ) <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/providers/types/#provider-transactionrequest">TransactionRequest</a></span><div class="anchors"><a class="self" href="#signer-checktransaction"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-signer/src.ts/index.ts#L132">source</a></div></div><div class="body"><p>This is generally not required to be overridden, but may 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 <code class="inline">call</code>, <code class="inline">estimateGas</code> and <code class="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 valid <a href="/api/providers/types/#provider-transactionrequest">TransactionRequest</a> properties exist and adds <code class="inline">from</code> to the transaction if it does not exist, or verifies it is equal to the Signer's address if it does exist.</p></div></div>
<a name="signer-populatetransaction"></a><div class="property show-anchors"><div class="signature"><span class="path">signer</span> . <span class="method">populateTransaction</span> ( <span class="param">transactionRequest</span> ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;<a href="/api/providers/types/#provider-transactionrequest">TransactionRequest</a>&thinsp;&gt;</span><div class="anchors"><a class="self" href="#signer-populatetransaction"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-signer/src.ts/index.ts#L163">source</a></div></div><div class="body"><p>This is generally not required to be overridden, but may 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 <code class="inline">checkTransaction</code> and fill in any properties required for sending a transaction. The result should have all promises resolved; if needed the <a href="/api/utils/properties/#utils-resolveproperties">resolveProperties</a> utility function can be used for this.</p><p>The default implementation calls <code class="inline">checkTransaction</code> and resolves to if it is an ENS name, adds <code class="inline">gasPrice</code>, <code class="inline">nonce</code>, <code class="inline">gasLimit</code> and <code class="inline">chainId</code> based on the related operations on Signer.</p></div></div>
<a name="wallet"></a><a name="wallet"></a><h2 class="show-anchors"><div>Wallet<span class="inherits"> inherits <a href="/api/signer/#externally-owned-account">ExternallyOwnedAccount</a> and <a href="/api/signer/#signer">Signer</a></span><div class="anchors"><a class="self" href="#wallet"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/wallet/src.ts/index.ts#L30">source</a></div></div></h2>
<p>The Wallet class inherits <a href="/api/signer/#signer">Signer</a> and can sign transactions and messages using a private key as a standard Externally Owned Account (EOA).</p>
<a name="wallet-constructor"></a><div class="property show-anchors"><div class="signature"><span class="modifier">new </span><span class="path">ethers</span> . <span class="method">Wallet</span> ( <span class="param">privateKey</span> [ , <span class="param">provider</span> ] ) <div class="anchors"><a class="self" href="#wallet-constructor"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/wallet/src.ts/index.ts#L40">source</a></div></div><div class="body"><p>Create a new Wallet instance for <i>privateKey</i> and optionally connected to the <i>provider</i>.</p></div></div>
<a name="wallet-createrandom"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span> . <span class="path">Wallet</span> . <span class="method">createRandom</span> ( [ <span class="param">options</span> = <span class="default-value">{</span>} ] ) <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/signer/#wallet">Wallet</a></span><div class="anchors"><a class="self" href="#wallet-createrandom"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/wallet/src.ts/index.ts#L143">source</a></div></div><div class="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>
<a name="wallet-fromencryptedjson"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span> . <span class="path">Wallet</span> . <span class="method">fromEncryptedJson</span> ( <span class="param">json</span> , <span class="param">password</span> [ , <span class="param">progress</span> ] ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;<a href="/api/signer/#wallet">Wallet</a>&thinsp;&gt;</span><div class="anchors"><a class="self" href="#wallet-fromencryptedjson"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/wallet/src.ts/index.ts#L156">source</a></div></div><div class="body"><p>Create an instance from an encrypted JSON wallet. If <i>progress</i> is provided it will be called during decryption with a value between 0 and 1 indicating the progress towards completion.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">ethers</span> . <span class="path">Wallet</span> . <span class="method">fromMnemonic</span> ( <span class="param">mnemonic</span> [ , <span class="param">path</span> , [ <span class="param">wordlist</span> ] ] ) <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/signer/#wallet">Wallet</a></span><div class="anchors"></div></div><div class="body"><p>Create an instance from a mnemonic phrase.</p><p>If path is not specified, the Ethereum default path is used (i.e. m/44'/60'/0'/0/0).</p><p>If wordlist is not specified, the English Wordlist is used.</p></div></div>
<a name="properties"></a><h3 class="show-anchors"><div>Properties<div class="anchors"><a class="self" href="#properties"></a></div></div></h3>
<div class="property show-anchors"><div class="signature"><span class="path">wallet</span> . <span class="method">address</span> <span class="arrow">&rArr;</span> <span class="returns">string&lt;&thinsp;<a href="/api/utils/address/#address">Address</a>&thinsp;&gt;</span><div class="anchors"></div></div><div class="body"><p>The address for the account this Wallet represents.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">wallet</span> . <span class="method">provider</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/providers/provider/">Provider</a></span><div class="anchors"></div></div><div class="body"><p>The provider this wallet is connected to, which will ge used for any <a href="/api/signer/#signer-blockchain">Blockchain Methods</a> methods. This can be null.</p></div></div>
<div class="definition container-box note show-anchors"><div class="term">Note</div><div class="body"><p>A <b>Wallet</b> instance is immuatable, so if you wish to change the Provider, you may use the <a href="/api/signer/#signer-connect">connect</a> method to create a new instance connected to the desired provider.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">wallet</span> . <span class="method">publicKey</span> <span class="arrow">&rArr;</span> <span class="returns">string&lt;&thinsp;<a href="/api/utils/bytes/#datahexstring">DataHexstring</a>&lt;&thinsp;65&thinsp;&gt;&thinsp;&gt;</span><div class="anchors"></div></div><div class="body"><p>The uncompressed public key for this Wallet represents.</p></div></div>
<a name="methods"></a><h3 class="show-anchors"><div>Methods<div class="anchors"><a class="self" href="#methods"></a></div></div></h3>
<div class="property show-anchors"><div class="signature"><span class="path">wallet</span> . <span class="method">encrypt</span> ( <span class="param">password</span> , [ <span class="param">options</span> = <span class="default-value">{</span>} , [ <span class="param">progress</span> ] ] ) <span class="arrow">&rArr;</span> <span class="returns">Promise&lt;&thinsp;string&thinsp;&gt;</span><div class="anchors"></div></div><div class="body"><p>Encrypt the wallet using <i>password</i> returning a Promise which resolves to a JSON wallet.</p></div></div>
<a name="void-signer"></a><a name="voidsigner"></a><h2 class="show-anchors"><div>VoidSigner<span class="inherits"> inherits <a href="/api/signer/#signer">Signer</a></span><div class="anchors"><a class="self" href="#void-signer"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/abstract-signer/src.ts/index.ts#L210">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 <code class="inline">call</code> operation will automatically have the provided address passed along during the execution.</p>
<div class="property show-anchors"><div class="signature"><span class="modifier">new </span><span class="path">ethers</span> . <span class="method">VoidSigner</span> ( <span class="param">address</span> ) <span class="arrow">&rArr;</span> <span class="returns"><a href="/api/signer/#void-signer">VoidSigner</a></span><div class="anchors"></div></div><div class="body"><p>Create a new instance of a <b>VoidSigner</b> for <i>address</i>.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">voidSigner</span> . <span class="method">address</span> <span class="arrow">&rArr;</span> <span class="returns">string&lt;&thinsp;<a href="/api/utils/address/#address">Address</a>&thinsp;&gt;</span><div class="anchors"></div></div><div class="body"><p>The address of this <b>VoidSigner</b>.</p></div></div>
<a name="externally-owned-account"></a><a name="externallyownedaccount"></a><h2 class="show-anchors"><div>ExternallyOwnedAccount<div class="anchors"><a class="self" href="#externally-owned-account"></a></div></div></h2>
<div class="property show-anchors"><div class="signature"><span class="path">eoa</span> . <span class="method">address</span> <span class="arrow">&rArr;</span> <span class="returns">string&lt;&thinsp;<a href="/api/utils/address/#address">Address</a>&thinsp;&gt;</span><div class="anchors"></div></div><div class="body"><p>The <a href="/api/utils/address/#address">Address</a> of this EOA.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">eoa</span> . <span class="method">privateKey</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"></div></div><div class="body"><p>The privateKey of this EOA</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">eoa</span> . <span class="method">mnemonic</span> <span class="arrow">&rArr;</span> <span class="returns">string</span><div class="anchors"></div></div><div class="body"><p><i>Optional</i>. The account HD mnemonic, if it has one and can be determined.</p></div></div>
<div class="property show-anchors"><div class="signature"><span class="path">eoa</span> . <span class="method">path</span> <span class="arrow">&rArr;</span> <span class="returns">string</span><div class="anchors"></div></div><div class="body"><p><i>Optional</i>. The account HD path, if it has one and can be determined.</p></div></div><div class="footer"><div class="nav previous"><a href="/api/contract/"><span class="arrow">&larr;</span>Contracts</a></div> <div class="nav next"><a href="/api/providers/">Providers<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:f8ad55e1a73a42b6c441ffc866de012dd177e039cf868ef8e53fd2cfd9ab35df -->