Description
A token looks like the easiest contract you will ever write. It is a mapping from address to number and a couple of functions to move the number around. Then it goes live, an exchange lists it, a lending market accepts it as collateral, and every assumption you made quietly becomes load bearing. The approve pattern you copied lets an old allowance get spent twice. The eighteen decimals you assumed do not match the six the stablecoin uses, and your math is off by a trillion. The proxy you added so you could fix bugs later reorders a storage slot on the next upgrade and hands one user another user balance. The real-world asset you swore was backed one to one has no honest way to prove it on chain. None of these is a syntax error. They are the specific ways a token that holds value goes wrong once the world starts trusting it, and by then the number in the mapping belongs to someone who will not forgive an off-by-one.
This book teaches you to build tokens the way the people who put real value behind them build them: assuming the balance is somebody savings, the approval will be abused, the price feed will lie, and the upgrade will try to corrupt your storage. It starts from what a token actually is, a shared ledger with rules, and builds the model you need to ship one safely. It covers the ERC-20 standard and its sharp edges, the approve and allowance race that has drained real wallets and the safe way to grant spending; ERC-721 and ERC-1155 for unique and mixed assets and where their transfer hooks bite; minting, burning, and supply control that a treasury can trust; the three stablecoin designs, fiat backed, crypto backed, and algorithmic, and why one of them keeps failing; the proxy upgrade patterns and the storage-layout rule that decides whether your next deploy fixes a bug or creates one; role-based access so no single key can rug the token; permissioned and compliant tokens that can freeze, allowlist, and answer to a regulator without a backdoor; tokenizing a real-world asset and proving the backing; pricing that asset with an oracle that cannot be manipulated in a single block; and a deployment checklist for the day the token goes live and stops being yours. The running example is one token system you build across the chapters, a fiat-backed unit and the tokenized gold behind it, reviewed for the exact ways each piece gets someone hurt. For engineers who are going to ship a token other people trust and want to be the one whose decimals, approvals, and upgrades never lost a cent.
Who this book is for
This book is for: engineers who can write a smart contract and now have to ship a token that other people will hold, trade, and lend against, where the balance in a mapping is somebody real money and a wrong decimal, a stale approval, or a shifted storage slot is a loss nobody can reverse.
The full table of contents
- Chapter 1: The day a mapping became somebody’s savings
- Chapter 2: The approval you granted last month just got spent twice
- Chapter 3: How do I make one token that nobody can copy?
- Chapter 4: One contract, a thousand assets, and I’m out of gas deploying them all
- Chapter 5: Who is allowed to print money, and how do I stop them?
- Chapter 6: Why does the coin that promised one dollar keep going to zero?
- Chapter 7: I shipped a bug into a contract I can’t edit. Now what?
- Chapter 8: One leaked key just minted a billion tokens
- Chapter 9: The regulator wants me to freeze an address. Can my token even do that?
- Chapter 10: I put a gold bar on chain. How does anyone know it’s really there?
- Chapter 11: My token’s price came from a feed that lied for one block
- Chapter 12: The day the token stopped being mine


