2019-08-22 08:52:17 +03:00
|
|
|
-----
|
|
|
|
|
|
|
|
Documentation: [html](https://docs-beta.ethers.io/)
|
|
|
|
|
|
|
|
-----
|
|
|
|
|
2019-08-21 08:53:47 +03:00
|
|
|
|
|
|
|
Addresses
|
|
|
|
=========
|
|
|
|
|
|
|
|
|
|
|
|
Explain addresses,formats and checksumming here.
|
|
|
|
|
2019-12-14 06:05:10 +03:00
|
|
|
Also see: [constants.AddressZero](../constants)
|
2019-08-21 08:53:47 +03:00
|
|
|
|
|
|
|
|
2020-02-02 08:53:22 +03:00
|
|
|
Address Formats
|
|
|
|
---------------
|
2019-08-21 08:53:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
2020-02-02 08:53:22 +03:00
|
|
|
### Address
|
|
|
|
|
|
|
|
|
|
|
|
An **Address** is a [DataHexstring](../bytes) 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](https://en.wikipedia.org/wiki/International_Bank_Account_Number)
|
|
|
|
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](./).
|
|
|
|
|
|
|
|
|
|
|
|
Functions
|
|
|
|
---------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### *utils* . **getAddress** ( address ) **=>** *string< [Address](./) >*
|
2019-08-21 08:53:47 +03:00
|
|
|
|
2019-12-14 06:05:10 +03:00
|
|
|
Returns *address* as a Checksum Address.
|
|
|
|
|
|
|
|
If *address* is an invalid 40-nibble [Hexstring](../bytes) 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.
|
2019-08-21 08:53:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#### *utils* . **isAddress** ( address ) **=>** *boolean*
|
|
|
|
|
2019-12-14 06:05:10 +03:00
|
|
|
Returns true if *address* is valid (in any supported format).
|
2019-08-21 08:53:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-02-02 08:53:22 +03:00
|
|
|
#### *utils* . **getIcapAddress** ( address ) **=>** *string< [IcapAddress](./) >*
|
2019-08-21 08:53:47 +03:00
|
|
|
|
2020-02-02 08:53:22 +03:00
|
|
|
Returns *address* as an [ICAP address](https://github.com/ethereum/wiki/wiki/Inter-exchange-Client-Address-Protocol-%28ICAP%29).
|
|
|
|
Supports the same restrictions as [utils.getAddress](./).
|
2019-08-21 08:53:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-02-02 08:53:22 +03:00
|
|
|
#### *utils* . **getContractAddress** ( transaction ) **=>** *string< [Address](./) >*
|
2019-08-21 08:53:47 +03:00
|
|
|
|
2019-12-14 06:05:10 +03:00
|
|
|
Returns the contract address that would result if *transaction* was
|
|
|
|
used to deploy a contract.
|
2019-08-21 08:53:47 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-02-02 08:53:22 +03:00
|
|
|
#### *utils* . **getCreate2Address** ( from , salt , initCodeHash ) **=>** *string< [Address](./) >*
|
|
|
|
|
|
|
|
Returns the contract address that would result from the given
|
|
|
|
[CREATE2](https://eips.ethereum.org/EIPS/eip-1014) call.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-21 08:53:47 +03:00
|
|
|
|
|
|
|
-----
|
2020-02-02 08:53:22 +03:00
|
|
|
**Content Hash:** 7835c97c8afbbdf59c39d32a9d79d86c4e446a2ed6acd6eae1f21c0b190b73c1
|