Sub topic 2
Accounts and addresses: where funds are sent
This chapter assumes you know that a private key controls an account, that a public key is derived from it, and that a blockchain is a shared ledger. You should also be comfortable reading short JavaScript snippets. The previous chapter covered keys and wallets. Here we focus on the address, which is the destination you type or paste when you send funds.
What an address is
An address is a short identifier for an account on a network. You share it so others can send you funds. It works like a bank account number: anyone can send to it, and only the holder of the matching private key can spend from it.
On Ethereum and other EVM chains (networks compatible with the Ethereum Virtual Machine), the address is derived from the public key:
- Take the uncompressed public key (64 bytes, without the leading format byte).
- Hash it with Keccak-256.
- Keep the last 20 bytes.
- Write them as 40 hexadecimal characters with a
0xprefix.
The derivation runs in one direction only. You can compute an address from a public key, but you cannot recover the public key or private key from an address. That is why sharing an address is safe.
Other networks use different formats. Bitcoin addresses begin with 1, 3, bc1q or bc1p, depending on the script type. Solana addresses are base58-encoded 32-byte public keys. An address is only meaningful on networks that share its format, and format alone does not tell you which network you are on. The networks chapter covers that problem in detail.
Two kinds of accounts on EVM chains
EVM chains have two account types, and both have addresses.
| Property | Externally owned account (EOA) | Contract account |
|---|---|---|
| Controlled by | A private key | Code deployed at the address |
| Can start a transaction | Yes | No, only react to calls |
| Has a nonce | Yes, counts sent transactions | Yes, counts contracts it created |
| Has code | No | Yes |
| Typical use | A person's wallet | Token contracts, exchanges, multisigs, smart accounts |
When you use a normal wallet app, you control an EOA. When you send to a token contract or a multisig wallet, you send to a contract account. The two look identical on the surface: both are 20-byte addresses. You can tell them apart by asking the node whether code exists at the address.
import { JsonRpcProvider } from "ethers";
const provider = new JsonRpcProvider(process.env.RPC_URL);
const address = process.env.ADDRESS;
const code = await provider.getCode(address);
console.log(code === "0x" ? "EOA (no code)" : "Contract account");getCode returns "0x" when there is no code. One edge case matters: an address that has never been used also returns "0x". It is a valid destination, and funds sent there are held until someone with the matching key spends them. A contract that has not been deployed yet, or has self-destructed, looks the same.
What an account holds
An EVM account is a record in the network's state with four fields:
balance: the amount of the native coin, stored in the smallest unit (wei for Ether, where 1 ether is 10^18 wei).nonce: a counter used to order transactions. The nonces chapter explains it.codeHash: a hash of the account's code, or the hash of empty data for an EOA.storageRoot: the root of the account's storage, which is empty for an EOA.
Accounts do not need to be created. The state has no entry for an address until it first receives funds or is otherwise touched. Generating a key pair and computing its address is enough to have a usable destination, and no registration with the network is needed.
Tokens are not stored in the account record. A token balance lives inside the token contract's own storage, as a mapping from address to amount. Your address "holds" tokens only because a contract says so. This explains why sending tokens needs gas in the native coin, and it is covered in the native versus token chapter.
Checksums and why the capitalization matters
EVM addresses are case-insensitive for the computer, since hexadecimal digits a and A are the same value. EIP-55 uses this to add an error check. The address is hashed, and each letter is capitalized or lowercased depending on the matching hash bits. The result is a mixed-case address that carries a checksum.
Libraries validate this for you:
import { getAddress, isAddress } from "ethers";
const lower = "0x52908400098527886e0f7030069857d2e4169ee7";
const checksummed = getAddress(lower);
console.log(checksummed);
// 0x52908400098527886E0F7030069857D2E4169EE7
console.log(isAddress(checksummed)); // true
// Change one letter's case and the checksum fails
const broken = "0x52908400098527886e0F7030069857D2E4169EE7";
try {
getAddress(broken);
} catch (err) {
console.log("Rejected:", err.code);
}Behavior to remember:
- An all-lowercase or all-uppercase address is accepted without a checksum check.
getAddressconverts it to the checksummed form. - A mixed-case address with a wrong case pattern is rejected. This catches most typing mistakes, since a single wrong character changes the expected capitalization with high probability.
- The checksum catches accidental errors. It does not protect against someone deliberately giving you a different, valid address.
Address formats on other chains
Different networks encode accounts differently, and a wallet app may hide this. The table shows common examples.
| Network family | Example prefix or shape | Notes |
|---|---|---|
| EVM (Ethereum, Polygon, Arbitrum, BNB Chain) | `0x` plus 40 hex characters | Same address works on every EVM chain |
| Bitcoin | `bc1q...`, `bc1p...`, `1...`, `3...` | A new address is usually generated per payment |
| Solana | 32 to 44 base58 characters | The address is the public key itself |
| Cosmos chains | Bech32, such as `cosmos1...` | The prefix names the chain |
Two consequences follow. First, the same private key can produce an EVM address that is valid on many networks, so the address alone never tells you which network will receive a payment. Second, a Bitcoin address pasted into an EVM wallet fails validation, which is a useful protection. Two EVM networks share the same format, so such a mistake passes validation silently.
One address, many networks
On EVM chains, your address is the same on Ethereum, Polygon, Arbitrum, Base and every other EVM network. The key pair is the same and so is the derivation. Balances are separate, however, because each network keeps its own ledger.
Suppose your address is 0xAb.... It may hold 1 ETH on Ethereum and 0 on Base. Sending funds to 0xAb... on the wrong network does not make them disappear in most cases: they sit at that address on the other network, and your key still controls them. You can reach them by adding that network to your wallet. The exception is a destination you do not control, such as an exchange deposit address or a contract that does not exist on the other network. Funds sent there may be unrecoverable.
Contract addresses add a further risk. An address that is a contract on one network may be empty on another, or controlled by a different party. Sending to a contract address that does not exist on the chosen network means nobody holds a key for it.
Name services
Hex addresses are hard to read, so some networks offer human-readable names. The Ethereum Name Service (ENS) maps names like alice.eth to addresses. A wallet or library resolves the name to an address before the transaction is built.
import { JsonRpcProvider } from "ethers";
const provider = new JsonRpcProvider(process.env.MAINNET_RPC_URL);
const resolved = await provider.resolveName("vitalik.eth");
console.log(resolved);Some points to keep in mind:
- The transaction itself contains only the resolved address, never the name.
- A name can be reassigned or its record changed. Resolve it again just before you send, and check the result.
- Look-alike names exist.
alice.ethandalice-.eth, or names with visually similar Unicode characters, can point to different owners. resolveNamereturnsnullwhen the name has no address set. Handle this case instead of passingnullalong.
Address poisoning and similar traps
Because people compare only the start and end of an address, attackers generate addresses with matching beginnings and endings. They send a tiny transaction from that look-alike address so it appears in your history. If you later copy an address from history, you may copy the attacker's.
Practical defenses:
- Copy addresses from a trusted source, not from transaction history.
- Compare the whole address, not only its edges.
- Send a small test amount before a large transfer to a new destination.
- Save verified recipients in your wallet's address book.
Reusing and generating addresses
Reuse policy depends on the model. On account-based chains such as EVM, reusing one address is normal, and your balance is a single number on that account. Everything you do is publicly linked to the address, so privacy is limited. On Bitcoin, wallets typically generate a fresh address for each receive, which the next chapter on account and UTXO models explains.
Hierarchical deterministic (HD) wallets derive many addresses from one seed phrase using a derivation path such as m/44'/60'/0'/0/0. The last number is the account index. Changing it yields a new address from the same seed, and your wallet app can show all of them.
import { HDNodeWallet, Mnemonic } from "ethers";
const mnemonic = Mnemonic.fromPhrase(process.env.TEST_MNEMONIC);
for (let i = 0; i < 3; i++) {
const wallet = HDNodeWallet.fromMnemonic(mnemonic, `m/44'/60'/0'/0/${i}`);
console.log(i, wallet.address);
}Use a throwaway test phrase here, never one that protects real funds.
Checklist before you send to an address
- Confirm the address format matches the network you intend to use.
- Check the checksum or let the library validate it.
- Compare the full address from a trusted source.
- Decide whether the destination is an EOA or a contract, and whether it can receive on that network.
- For a new or large payment, send a small test amount first.
Exercise
Your friend gives you the address 0x52908400098527886E0F7030069857D2E4169EE7. You copy it but accidentally change one lowercase letter to uppercase, and then validate it with ethers. What happens, and does a successful validation prove you are paying your friend?
Show answer
If the changed letter breaks the EIP-55 capitalization pattern, getAddress and isAddress reject the mixed-case address, which is how the checksum catches typing errors. A passing check would show only that the text is internally consistent. It would not prove the address belongs to your friend, so you should still compare it with a trusted source and consider a small test transfer.
Exercise
You have the same address on Ethereum and on Base, and you send funds to an address you control while the wrong network is selected. Are the funds lost? Name one case in which they would be.
Show answer
Usually not. EVM addresses are identical across EVM networks, so the funds are at your address on the other network, and adding that network to your wallet reveals them. They can be lost if the destination is not controlled by you on that network, such as an exchange deposit address that is not supported there, or a contract address that does not exist on that chain.