#
Addresses

Explain addresses,formats and checksumming here.

Also see: constants.AddressZero

##
Address Formats

###
Address

An Address is a DataHexString of 20 bytes (40 nibbles), with optional mixed case.

If the case is mixed, it is a Checksum Address, 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.

All functions that return an Address will return a Checksum Address.

###
ICAP Address

The ICAP Address Format was an early attempt to introduce a checksum into Ethereum addresses using the popular banking industry's IBAN format with the country code specified as XE.

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 `0` as the first byte, which allows the address to be formatted as a fully compatibly standard IBAN address with 30 base-36 characters.

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.

To convert an address into the ICAP format, see getIcapAddress.

##
Converting and Verifying

ethers.utils.getAddress( address ) ⇒ string< Address >
source

Returns address as a Checksum Address.

If address is an invalid 40-nibble HexString or if it contains mixed case and the checksum is invalid, an InvalidArgument Error is throw.

The value of address may be any supported address format.

ethers.utils.getIcapAddress( address ) ⇒ string< IcapAddress >
source

Returns address as an ICAP address. Supports the same restrictions as utils.getAddress.

ethers.utils.isAddress( address ) ⇒ boolean
source

Returns true if address is valid (in any supported format).

##
Derivation

ethers.utils.computeAddress( publicOrPrivateKey ) ⇒ string< Address >
source

Returns the address for publicOrPrivateKey. A public key may be compressed or uncompressed, and a private key will be converted automatically to a public key for the derivation.

ethers.utils.recoverAddress( digest , signature ) ⇒ string< Address >
source

Use ECDSA Public Key Recovery to determine the address that signed digest to which generated signature.

##
Contracts Addresses

ethers.utils.getContractAddress( transaction ) ⇒ string< Address >
source

Returns the contract address that would result if transaction was used to deploy a contract.

ethers.utils.getCreate2Address( from , salt , initCodeHash ) ⇒ string< Address >
source

Returns the contract address that would result from the given CREATE2 call.

The content of this site is licensed under the Creative Commons License. Last modified on June 12, 2020, 7:17pm.