Understanding Ethereum Addresses: Formats, Checksums, and Key Functions

Β·

What Is an Ethereum Address?

An Ethereum address is a unique identifier used to send and receive transactions on the Ethereum blockchain. Technically, it's a 20-byte (40-character) hexadecimal string prefixed with "0x". Addresses can be written in lowercase, uppercase, or mixed caseβ€”the latter indicating a checksum address with built-in error detection.

Key Characteristics:

πŸ‘‰ Learn how to secure your Ethereum assets

Checksum Addresses: Reducing Errors

A checksum address incorporates uppercase and lowercase letters following the EIP-55 standard. This formatting:

Example:
0x8ba1f109551bD432803012645Ac136ddd64DBA72 (valid checksum)
0x8Ba1f109551bD432803012645Ac136ddd64DBA72 (invalid checksum, throws error)

ICAP Address Format (Legacy)

The Inter-exchange Client Address Protocol (ICAP) was an early attempt to align Ethereum addresses with the banking industry's IBAN format. Though mostly deprecated, it's still convertible:

Note: Most modern dApps no longer support ICAP natively.

Core Address Functions in Ethers.js

1. getAddress(address) β‡’ string

Converts any valid address format into a checksum address.

ethers.utils.getAddress("0x8ba1f109551bd432803012645ac136ddd64dba72");
// Returns: '0x8ba1f109551bD432803012645Ac136ddd64DBA72'

Throws errors for:

2. isAddress(address) β‡’ boolean

Validates any address format without conversion.

ethers.utils.isAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36"); // true
ethers.utils.isAddress("Invalid123"); // false

3. computeAddress(publicOrPrivateKey) β‡’ string

Derives an address from cryptographic keys:

// Private Key Example
ethers.utils.computeAddress("0xb976778317b23a1385ec2d483eda6904d9319135b89f1d8eee9f6d2593e2665d");
// Returns: '0x0Ac1dF02185025F65202660F8167210A80dD5086'

Supports:

4. recoverAddress(digest, signature) β‡’ string

Extracts the signer's address from a signed message digest.

const digest = "0x7c5ea36004851c764c44143b1dcb59679b11c9a68e5f41497f6cf3d480715331";
const signature = {
  r: "0x528459e4aec8934dc2ee94c4f3265cf6ce00d47cf42bb106afda3642c72e25eb",
  s: "0x42544137118256121502784e5a6425e6183ca964421ecd577db6c66ba9bccdcf",
  v: 27
};
ethers.utils.recoverAddress(digest, signature);
// Returns: '0x0Ac1dF02185025F65202660F8167210A80dD5086'

5. Contract Address Generation

a) getContractAddress(transaction)

Predicts a contract's address based on the deployer's nonce:

const from = "0x8ba1f109551bD432803012645Ac136ddd64DBA72";
const nonce = 5;
ethers.utils.getContractAddress({ from, nonce });
// Returns: '0x082B6aC9e47d7D83ea3FaBbD1eC7DAba9D687b36'

b) getCreate2Address(from, salt, initCodeHash)

Calculates deterministic addresses using EIP-1014 (CREATE2):

const from = "0x8ba1f109551bD432803012645Ac136ddd64DBA72";
const salt = "0x7c5ea36004851c764c44143b1dcb59679b11c9a68e5f41497f6cf3d480715331";
const initCodeHash = ethers.utils.keccak256("0x6394198df16000526103ff60206004601c335afa6040516060f3");
ethers.utils.getCreate2Address(from, salt, initCodeHash);
// Returns: '0x533ae9d683B10C02EbDb05471642F85230071FC3'

πŸ‘‰ Explore advanced Ethereum development tools

FAQ Section

Q1: Why do some Ethereum addresses have uppercase letters?

A: Uppercase letters indicate a checksum address (EIP-55 standard), which helps detect typing/copy-paste errors by embedding validation data in the letter casing.

Q2: Can I convert an ICAP address back to a hex address?

A: Yes, tools like ethers.utils.getAddress() automatically convert ICAP (XE...) addresses to standard hex format.

Q3: What happens if I send funds to a wrong-checksum address?

A: Transactions to incorrectly checksummed addresses will fail if the checksum validation is enforced by the receiving service. Otherwise, they may result in permanent fund loss.

Q4: How are contract addresses calculated differently?

A: Regular contract addresses use the sender's nonce, while CREATE2 addresses derive from a salt + init code hash, enabling pre-computation.

Q5: Is address zero (0x000...000) special?

A: Yes, constants.AddressZero represents an empty address often used in smart contracts for initialization or burn mechanisms.

Key Takeaways