Sub topic 2
Accounts and addresses: where funds are sent
Assume you know what a blockchain is and can use a wallet application. This chapter uses Ethereum-style accounts, but the main ideas apply to many account-based networks.
An account is more than an address
An account is a record of state maintained by a blockchain. On an Ethereum-style network, that state can include:
- A native-coin balance.
- A transaction nonce, which counts transactions sent by the account.
- Contract code, if the account is a smart contract.
- Contract storage, if the account is a smart contract.
An address is the short identifier used to find an account. Ethereum addresses are usually written as 42-character hexadecimal strings beginning with 0x. For example:
0x742d35Cc6634C0532925a3b844Bc454e4438f44e
A wallet does not contain coins directly. It controls one or more accounts by holding the credentials needed to authorize transactions.
How keys produce an address
A private key is a secret number that can authorize transactions. A public key is mathematically derived from the private key. An address is then derived from the public key using the network's address algorithm.
The important direction is one-way in practice:
private key → public key → addressYou can share an address. You must not share a private key or recovery phrase. Anyone with the private key can usually create a valid transaction that spends the account's funds.
A wallet may derive many accounts from one recovery phrase. The wallet displays the addresses and signs transactions, but the blockchain only sees the signed transaction and the resulting account changes.
flowchart TD
A[Private key or recovery phrase] --> B[Wallet derives key pair]
B --> C[Public key]
C --> D[Account address]
D --> E[Funds and transaction history]
B --> F[Wallet signs transaction]
F --> G[Network verifies signature]Externally owned accounts and contract accounts
Ethereum-style networks have two broad account types:
| Account type | Controlled by | Can sign transactions? | Typical use |
|---|---|---|---|
| Externally owned account | A private key | Yes | Personal wallet |
| Contract account | Deployed program logic | No, by itself | Token or application contract |
An externally owned account, or EOA, is the account most people use when sending funds. A contract account has an address too, but it responds according to its code. Sending assets to a contract is safe only when that contract is designed to receive and use those assets.
A token balance may not appear as the native balance of an address. For an ERC-20 token, the token contract stores a mapping between addresses and token amounts. The same address can therefore have a native-coin balance and separate balances for many tokens.
Address formats and network context
Some networks use different address formats. Even when two networks accept similar-looking addresses, they may have separate ledgers. An address can exist on several networks, but its balance and transaction history are network-specific.
Before sending, check:
- The recipient address is complete and correct.
- The selected network matches the recipient's network.
- The asset is supported on that network.
- The recipient expects a wallet address rather than a deposit address, memo, or tag.
- You have enough native coin to pay the transaction fee.
Wallets may display mixed-case checksum addresses. The capitalization can help detect typing errors, but it is not a substitute for verifying the address through a trusted channel.
Deriving an address in code
This example creates a new temporary wallet and prints its address. It does not send funds.
import { Wallet } from "ethers";
const wallet = Wallet.createRandom();
console.log("Address:", wallet.address);
console.log("Private key:", wallet.privateKey);Never print or store a real private key in application logs. In production, use a secure signer or wallet service instead of embedding secrets in source code.
Exercise
You receive an address that looks valid, but the sender selected a different network from the one you use. What should you do?
Show answer
Stop before sending. Confirm the intended network with the recipient and select that network in the wallet. Do not assume that a matching address format means the funds will arrive in the same account or be recoverable.