70 lines
16 KiB
HTML
70 lines
16 KiB
HTML
<!DOCTYPE html>
|
|
<html class="paged">
|
|
<head>
|
|
<title>Addresses</title>
|
|
<link rel="stylesheet" type="text/css" href="/v5/static/style.css">
|
|
</head>
|
|
<body>
|
|
<div class="sidebar">
|
|
<div class="header">
|
|
<div class="logo"><a href="/v5/"><div class="image"></div><div class="name">ethers</div><div class="version">v5.0</div></a></div>
|
|
</div>
|
|
<div class="toc"><div>
|
|
<div class="link title"><a href="/v5/">Documentation</a></div><div class="base show link depth-1"><a href="/v5/getting-started/">Getting Started</a></div><div class="base show link depth-1"><a href="/v5/concepts/">Ethereum Basics</a></div><div class="hide link depth-2"><a href="/v5/concepts/events/">Events</a></div><div class="hide link depth-2"><a href="/v5/concepts/gas/">Gas</a></div><div class="hide link depth-2"><a href="/v5/concepts/security/">Security</a></div><div class="base show link depth-1"><a href="/v5/api-keys/">Provider API Keys</a></div><div class="base ancestor show link depth-1"><a href="/v5/api/">Application Programming Interface</a></div><div class="show link depth-2"><a href="/v5/api/providers/">Providers</a></div><div class="hide link depth-3"><a href="/v5/api/providers/provider/">Provider</a></div><div class="hide link depth-3"><a href="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><div class="hide link depth-3"><a href="/v5/api/providers/api-providers/">API Providers</a></div><div class="hide link depth-3"><a href="/v5/api/providers/other/">Other Providers</a></div><div class="hide link depth-3"><a href="/v5/api/providers/types/">Types</a></div><div class="show link depth-2"><a href="/v5/api/signer/">Signers</a></div><div class="show link depth-2"><a href="/v5/api/contract/">Contract Interaction</a></div><div class="hide link depth-3"><a href="/v5/api/contract/contract/">Contract</a></div><div class="hide link depth-3"><a href="/v5/api/contract/contract-factory/">ContractFactory</a></div><div class="hide link depth-3"><a href="/v5/api/contract/example/">Example: ERC-20 Contract</a></div><div class="ancestor show link depth-2"><a href="/v5/api/utils/">Utilities</a></div><div class="show link depth-3"><a href="/v5/api/utils/abi/">Application Binary Interface</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/coder/">AbiCoder</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/formats/">ABI Formats</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/fragments/">Fragments</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/interface/">Interface</a></div><div class="myself ancestor ancestor show link depth-3"><a href="/v5/api/utils/address/">Addresses</a></div><div class="show link depth-3"><a href="/v5/api/utils/bignumber/">BigNumber</a></div><div class="show link depth-3"><a href="/v5/api/utils/bytes/">Byte Manipulation</a></div><div class="show link depth-3"><a href="/v5/api/utils/constants/">Constants</a></div><div class="show link depth-3"><a href="/v5/api/utils/display-logic/">Display Logic and Input</a></div><div class="show link depth-3"><a href="/v5/api/utils/encoding/">Encoding Utilities</a></div><div class="show link depth-3"><a href="/v5/api/utils/fixednumber/">FixedNumber</a></div><div class="show link depth-3"><a href="/v5/api/utils/hashing/">Hashing Algorithms</a></div><div class="show link depth-3"><a href="/v5/api/utils/hdnode/">HD Wallet</a></div><div class="show link depth-3"><a href="/v5/api/utils/logger/">Logging</a></div><div class="show link depth-3"><a href="/v5/api/utils/properties/">Property Utilities</a></div><div class="show link depth-3"><a href="/v5/api/utils/signing-key/">Signing Key</a></div><div class="show link depth-3"><a href="/v5/api/utils/strings/">Strings</a></div><div class="show link depth-3"><a href="/v5/api/utils/transactions/">Transactions</a></div><div class="show link depth-3"><a href="/v5/api/utils/web/">Web Utilities</a></div><div class="show link depth-3"><a href="/v5/api/utils/wordlists/">Wordlists</a></div><div class="show link depth-2"><a href="/v5/api/other/">Other Libraries</a></div><div class="hide link depth-3"><a href="/v5/api/other/assembly/">Assembly</a></div><div class="hide link depth-4"><a href="/v5/api/other/assembly/dialect/">Ethers ASM Dialect</a></div><div class="hide link depth-4"><a href="/v5/api/other/assembly/api/">Utilities</a></div><div class="hide link depth-4"><a href="/v5/api/other/assembly/ast/">Abstract Syntax Tree</a></div><div class="hide link depth-3"><a href="/v5/api/other/hardware/">Hardware Wallets</a></div><div class="show link depth-2"><a href="/v5/api/experimental/">Experimental</a></div><div class="base show link depth-1"><a href="/v5/cli/">Command Line Interfaces</a></div><div class="hide link depth-2"><a href="/v5/cli/ethers/">Sandbox Utility</a></div><div class="hide link depth-2"><a href="/v5/cli/asm/">Assembler</a></div><div class="hide link depth-2"><a href="/v5/cli/ens/">Ethereum Naming Service</a></div><div class="hide link depth-2"><a href="/v5/cli/typescript/">TypeScript</a></div><div class="hide link depth-2"><a href="/v5/cli/plugin/">Making Your Own</a></div><div class="base show link depth-1"><a href="/v5/cookbook/">Cookbook</a></div><div class="hide link depth-2"><a href="/v5/cookbook/react-native/">React Native (and ilk)</a></div><div class="base show link depth-1"><a href="/v5/migration/">Migration Guide</a></div><div class="hide link depth-2"><a href="/v5/migration/web3/">Migration: From Web3.js</a></div><div class="hide link depth-2"><a href="/v5/migration/ethers-v4/">Migration: From Ethers v4</a></div><div class="base show link depth-1"><a href="/v5/testing/">Testing</a></div><div class="base show link depth-1"><a href="/v5/contributing/">Contributing and Hacking</a></div><div class="base show link depth-1"><a href="/v5/documentation/">Flatworm Docs</a></div><div class="base show link depth-1"><a href="/v5/license/">License and Copyright</a></div>
|
|
</div></div>
|
|
</div>
|
|
<div class="content">
|
|
<div class="breadcrumbs"><a href="/v5/">Documentation</a> » <a href="/v5/api/">API</a> » <a href="/v5/api/utils/">Utilities</a> » <span class="current">Addresses</span></div>
|
|
|
|
<a name="addresses"></a><a name="addresses"></a><h1 class="show-anchors"><div>Addresses<div class="anchors"><a class="self" href="/v5/api/utils/address/#addresses"></a></div></div></h1><p>Explain addresses,formats and checksumming here.</p>
|
|
|
|
<p>Also see: <a href="/v5/api/utils/constants/">constants.AddressZero</a></p>
|
|
|
|
<a name="address-formats"></a><a name="addresses--address-formats"></a><h2 class="show-anchors"><div>Address Formats<div class="anchors"><a class="self" href="/v5/api/utils/address/#address-formats"></a></div></div></h2>
|
|
<a name="address"></a><a name="addresses--address-formats--address"></a><h3 class="show-anchors"><div>Address<div class="anchors"><a class="self" href="/v5/api/utils/address/#address"></a></div></div></h3><p>An <b>Address</b> is a <a href="/v5/api/utils/bytes/#DataHexString">DataHexString</a> of 20 bytes (40 nibbles), with optional mixed case.</p>
|
|
|
|
<p>If the case is mixed, it is a <b>Checksum Address</b>, which uses a specific pattern of uppercase and lowercase letters within a given address to reduce the risk of errors introduced from typing an address or cut and paste issues.</p>
|
|
|
|
<p>All functions that return an Address will return a Checksum Address.</p>
|
|
|
|
<a name="address-icap"></a><a name="addresses--address-formats--address-icap"></a><h3 class="show-anchors"><div>ICAP Address<div class="anchors"><a class="self" href="/v5/api/utils/address/#address-icap"></a></div></div></h3><p>The <b>ICAP Address Format</b> was an early attempt to introduce a checksum into Ethereum addresses using the popular banking industry's <a href="https://en.wikipedia.org/wiki/International_Bank_Account_Number">IBAN</a> format with the country code specified as <b>XE</b>.</p>
|
|
|
|
<p>Due to the way IBAN encodes address, only addresses that fit into 30 base-36 characters are actually compatible, so the format was adapted to support 31 base-36 characters which is large enough for a full Ethereum address, however the preferred method was to select a private key whose address has a <code class="inline">0</code> as the first byte, which allows the address to be formatted as a fully compatibly standard IBAN address with 30 base-36 characters.</p>
|
|
|
|
<p>In general this format is no longer widely supported anymore, however any function that accepts an address can receive an ICAP address, and it will be converted internally.</p>
|
|
|
|
<p>To convert an address into the ICAP format, see <a href="/v5/api/utils/address/#utils-getIcapAddress">getIcapAddress</a>.</p>
|
|
|
|
<a name="utils--address"></a><a name="addresses--utils--address"></a><h2 class="show-anchors"><div>Converting and Verifying<div class="anchors"><a class="self" href="/v5/api/utils/address/#utils--address"></a></div></div></h2>
|
|
<a name="utils-getAddress"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">getAddress</span><span class="symbol">(</span> <span class="param">address</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/address/#address">Address</a> ></span><div class="anchors"><a class="self" href="/v5/api/utils/address/#utils-getAddress"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/address/src.ts/index.ts#L80">source</a></div></div><div class="body"><p>Returns <i>address</i> as a Checksum Address.</p>
|
|
|
|
<p>If <i>address</i> is an invalid 40-nibble <a href="/v5/api/utils/bytes/#HexString">HexString</a> or if it contains mixed case and the checksum is invalid, an InvalidArgument Error is thrown.</p>
|
|
|
|
<p>The value of <i>address</i> may be any supported address format.</p>
|
|
|
|
</div></div><a name="utils-getIcapAddress"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">getIcapAddress</span><span class="symbol">(</span> <span class="param">address</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/address/#address-icap">IcapAddress</a> ></span><div class="anchors"><a class="self" href="/v5/api/utils/address/#utils-getIcapAddress"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/address/src.ts/index.ts#L126">source</a></div></div><div class="body"><p>Returns <i>address</i> as an <a href="https://github.com/ethereum/wiki/wiki/Inter-exchange-Client-Address-Protocol-%28ICAP%29">ICAP address</a>. Supports the same restrictions as <a href="/v5/api/utils/address/#utils-getAddress">utils.getAddress</a>.</p>
|
|
|
|
</div></div><a name="utils-isAddress"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">isAddress</span><span class="symbol">(</span> <span class="param">address</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="self" href="/v5/api/utils/address/#utils-isAddress"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/address/src.ts/index.ts#L118">source</a></div></div><div class="body"><p>Returns true if <i>address</i> is valid (in any supported format).</p>
|
|
|
|
</div></div><a name="utils--address-derivation"></a><a name="addresses--utils--address-derivation"></a><h2 class="show-anchors"><div>Derivation<div class="anchors"><a class="self" href="/v5/api/utils/address/#utils--address-derivation"></a></div></div></h2>
|
|
<a name="utils-computeAddress"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">computeAddress</span><span class="symbol">(</span> <span class="param">publicOrPrivateKey</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/address/#address">Address</a> ></span><div class="anchors"><a class="self" href="/v5/api/utils/address/#utils-computeAddress"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/transactions/src.ts/index.ts#L75">source</a></div></div><div class="body"><p>Returns the address for <i>publicOrPrivateKey</i>. A public key may be compressed or uncompressed, and a private key will be converted automatically to a public key for the derivation.</p>
|
|
|
|
</div></div><a name="utils-recoverAddress"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">recoverAddress</span><span class="symbol">(</span> <span class="param">digest</span> <span class="symbol">,</span> <span class="param">signature</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/address/#address">Address</a> ></span><div class="anchors"><a class="self" href="/v5/api/utils/address/#utils-recoverAddress"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/transactions/src.ts/index.ts#L80">source</a></div></div><div class="body"><p>Use <a href="https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm#Public_key_recovery">ECDSA Public Key Recovery</a> to determine the address that signed <i>digest</i> to which generated <i>signature</i>.</p>
|
|
|
|
</div></div><a name="utils--contract-addresses"></a><a name="addresses--utils--contract-addresses"></a><h2 class="show-anchors"><div>Contracts Addresses<div class="anchors"><a class="self" href="/v5/api/utils/address/#utils--contract-addresses"></a></div></div></h2>
|
|
<a name="utils-getContractAddress"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">getContractAddress</span><span class="symbol">(</span> <span class="param">transaction</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/address/#address">Address</a> ></span><div class="anchors"><a class="self" href="/v5/api/utils/address/#utils-getContractAddress"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/address/src.ts/index.ts#L133">source</a></div></div><div class="body"><p>Returns the contract address that would result if <i>transaction</i> was used to deploy a contract.</p>
|
|
|
|
</div></div><a name="utils-getCreate2Address"></a><div class="property show-anchors"><div class="signature"><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">getCreate2Address</span><span class="symbol">(</span> <span class="param">from</span> <span class="symbol">,</span> <span class="param">salt</span> <span class="symbol">,</span> <span class="param">initCodeHash</span> <span class="symbol">)</span> <span class="arrow">⇒</span> <span class="returns">string< <a href="/v5/api/utils/address/#address">Address</a> ></span><div class="anchors"><a class="self" href="/v5/api/utils/address/#utils-getCreate2Address"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/address/src.ts/index.ts#L146">source</a></div></div><div class="body"><p>Returns the contract address that would result from the given <a href="https://eips.ethereum.org/EIPS/eip-1014">CREATE2</a> call.</p>
|
|
|
|
</div></div>
|
|
|
|
<div class="footer">
|
|
<div class="nav previous"><a href="/v5/api/utils/abi/interface/"><span class="arrow">←</span>Interface</a></div>
|
|
<div class="nav next"><a href="/v5/api/utils/bignumber/">BigNumber<span class="arrow">→</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 License</a>. Generated on September 8, 2020, 1:8am.</div>
|
|
</div>
|
|
<script src="/v5/static/script.js" type="text/javascript"></script>
|
|
</body>
|
|
</html>
|