Part II · Accounts, transactions, contracts

Wallets, keys and signatures

By KangPublished: Chain snapshot: , block 12117419

A wallet mainly holds the power to sign, not a drawer inside some app where tokens sit.

Your tokens are not actually “in” the wallet

When you pay by bank card, the bank checks your identity and account permissions. On networks like Ethereum, an ordinary account uses a private key to produce a digital signature, and the network checks the signature to confirm the transaction was authorised.

  • An address is like a public account number. It is safe to share.
  • A private key is like a master permission that can never be reset: whoever holds it can sign anything in that address’s name.
  • Your token balance is actually recorded in a contract on-chain (for example, a balance table inside an ERC-20 contract). The wallet just reads it for you and signs on your behalf when you agree.
Five steps: the wallet signs with a local private key; the signed transaction; an RPC node checks it and holds it in the mempool; a validator includes it in a block; the explorer shows network, status, from, to, logs, block and hash.
Figure 2 ·

A signed transaction is broadcast, checked by nodes, included in a block by a validator, and then observed in a block explorer. The private key never leaves the wallet.

Open the full-size diagram in a new tab

Four actions, very different risks

  • Connecting a wallet tells a website one of your addresses. On its own it does not move any tokens.
  • Signing a message may be a harmless log-in statement, or it may grant a risky permission. Read it before you sign.
  • Sending a transaction changes on-chain state and usually costs a gas fee.
  • Exporting a seed phrase or private key means anyone who obtains it may control everything at that address. Legitimate sites almost never need you to do this.

Seed phrases, private keys and API keys

All of these may have “key” in their name, but the risks differ completely:

Name What it can do If it leaks
Private key Sign transactions: transfer, deploy contracts, approve tokens Someone can spend everything at that address
Seed phrase (usually 12 or 24 words) Restore a whole wallet (possibly many keys) Worse than one key: the entire wallet is taken over
API key (for example Etherscan’s) Call a website’s API in your name Usually cannot move assets, but your quota can be used up or abused in your name
Address A public “house number” Not a secret; being misled to a fake address is the real risk

Appendix B explains how to obtain and store an API key.

How the labs handled this

  • Accounts A and B were both freshly generated locally as disposable test accounts. No real wallet seed phrase was ever imported, and neither was ever used on mainnet.
  • The private keys lived only in a local, Git-ignored folder (folder permission 700, file permission 600). They were never printed and never written into public records or this book.
  • Broadcast scripts checked that the account’s ETH balance was no more than 0.1 ETH, as a guard against accidentally using a key that might hold mainnet funds.

The public addresses of the two test accounts (addresses only, not keys):