2.1 How Tokens Work: The Basic Mechanics
Tokens aren't files. They're not downloaded to your wallet. They're not stored on your device.
They're entries in a database replicated across thousands of computers worldwide.
Your wallet doesn't hold tokens. It holds private keys that prove you can modify specific entries in the blockchain's ledger. When someone "sends" you 100 USDC, nothing physically moves. A smart contract updates its internal record: your address now appears next to the number 100.
This changes ownership completely. Gold requires a vault. Stock certificates require custody. Real estate requires deeds and title companies. Tokens require only cryptographic proof. Your private key is the entire evidence of ownership.
No intermediary. No custodian. No company holding your assets "on your behalf."
State Changes: The Core Mechanic
Every token action rewrites the blockchain's state.
Picture an ERC-20 token contract as a spreadsheet. Two columns: addresses and balances. Alice has 500 tokens. Bob has 200. When Alice sends 100 tokens to Bob, nothing moves between them. The contract rewrites two numbers:
Alice: 500 → 400
Bob: 200 → 300
That's the entire transfer. One function call. Two storage updates. Done.
Ethereum stores these changes across 10,000+ nodes [1]. Reversing a confirmed transaction means compromising the majority of these nodes. For established networks, economically impossible.
This architecture enables something traditional finance can't match: Bob doesn't need to be online. He doesn't need to accept the transfer. He doesn't even need a wallet yet. The blockchain's state records the fact. When Bob checks his balance next week, the 100 tokens exist because the ledger says they do.
The Anatomy of a Token Transfer
Watch what happens when you click "send."
Step 1: Transaction Construction
Your wallet builds instructions for the token contract. It includes the recipient's address, the amount, and your digital signature proving you control the sending address.
No token data moves anywhere. You're creating a command for the contract to execute.
Step 2: Network Propagation
Your transaction broadcasts to thousands of nodes within seconds. They verify your signature, check the contract code, and add the transaction to their memory pool. This happens before any validator touches it. The network performs the first security check automatically [2].
Step 3: Execution and Validation
A validator includes your transaction in a new block. The token contract executes:
Four lines. Two storage updates. One event emission. That's the complete mechanism for most fungible tokens.
Step 4: Consensus and Finality
The block gets added to the blockchain. On Ethereum, this happens roughly every 12 seconds [3]. Other validators confirm the block's validity. After a few more blocks build on top, reversal becomes statistically impossible.
The entire process: 15-60 seconds on Ethereum. 2-3 seconds on Solana [4]. No central authority approves anything.
Storage: Where Your Balance Actually Lives
Token balances live in the contract's storage. A key-value database maintained by the blockchain.
For ERC-20 tokens, storage contains:
Address-to-balance mappings:
mapping(address => uint256) balancesAllowances for delegated transfers:
mapping(address => mapping(address => uint256)) allowedTotal supply:
uint256 totalSupplyMetadata:
string name,string symbol
Reading this storage costs nothing. Anyone can check any address's balance anytime without paying fees. MetaMask, Etherscan, every block explorer queries this storage constantly.
Writing to storage costs gas. Every balance update requires paying validators to update their database and broadcast changes. A typical ERC-20 transfer modifies two storage slots. Cost: $0.50-$5 depending on network congestion [5].
This explains the gas fee confusion newcomers face. Moving 10 tokens or 10,000 tokens costs exactly the same. You're updating the same number of storage slots either way. The value transferred doesn't matter. What matters is how much storage you're modifying.
Events: The Blockchain's Announcement System
Smart contracts can't email you. They can't send push notifications. They emit events instead.
When a token transfer completes, the contract emits a Transfer event:
This event becomes part of the blockchain's permanent record. Wallets monitor these events to detect incoming transfers. Block explorers index them to show transaction history. DeFi protocols listen for specific events to trigger automated actions.
Watch how this works in practice. Compound's lending protocol monitors token approval events. When you approve Compound to spend your USDC, an Approval event fires. Compound detects this and knows it can now pull funds from your address [6].
Events cost minimal gas but provide maximum transparency. Every token interaction leaves a trail anyone can audit. The entire history of every token exists in these event logs. Every transfer. Every approval. Every mint. Forever.
Approvals: Delegated Token Control
This mechanic confuses newcomers more than any other.
Direct transfers are simple: you send tokens to someone. But protocols need to move tokens on your behalf. Uniswap needs to take your tokens when you trade. Lending protocols need to pull tokens when you deposit.
The approval mechanism solves this. You call approve(spenderAddress, amount) to grant a contract permission to spend up to a specified amount. The contract stores this allowance:
Now the protocol can call transferFrom(yourAddress, destinationAddress, amount) to move tokens from your account. Without you signing a new transaction. You've already given permission.
This creates both functionality and risk.
Infinite approvals are common but dangerous. Set amount to max uint256, and that contract can drain all your tokens if it gets hacked or turns malicious. DeFi users routinely grant approvals to dozens of protocols. Most never revoke them [7].
Modern wallets now warn about approval amounts. Smart users approve only what's needed for each transaction. Paranoid users regularly revoke old approvals through sites like Revoke.cash [8].
Gas: The Cost of State Changes
Every token operation costs gas. The fee paid to validators for executing your transaction and updating blockchain state.
Gas prices fluctuate with network demand. During normal periods, an ERC-20 transfer costs 50,000-70,000 gas units. At $1 per unit (measured in gwei), that's $50-70. During DeFi summer 2021, gas prices hit $20+ per unit. Simple transfers cost hundreds of dollars [9].
Layer 2 solutions attack this problem directly. Optimism, Arbitrum, and other L2s batch hundreds of transactions together, spreading costs across users. A token transfer that costs $5 on Ethereum mainnet might cost $0.10 on Arbitrum [10].
Solana takes a different approach. Its architecture enables 65,000+ transactions per second at fractions of a penny [11]. This makes microtransactions economically viable.
Paying $0.50 to send $1 makes no sense. Paying $0.0001 to send $1 works fine.
Understanding gas mechanics affects when you transact (weekends are cheaper), which networks you choose (L2s for small amounts), and how you structure approvals (batch operations when possible).
Reading vs. Writing: The Cost Asymmetry
Reading blockchain data is free. Writing costs money.
Check your token balance: free. Check someone else's balance: free. See total token supply: free. View entire transaction history: free. These read operations query blockchain state without modifying it.
Transfer tokens: costs gas. Approve spending: costs gas. Mint new tokens: costs gas. These write operations modify state and require consensus across thousands of nodes.
This asymmetry drives architectural decisions throughout crypto. DeFi protocols minimize writes and maximize reads. Chainlink oracles update price feeds only when values change significantly. Each update costs gas. Automated market makers store minimal state, calculating prices on-demand from current reserves [12].
Users feel this asymmetry daily. Checking your portfolio in MetaMask: instant and free. Actually moving those tokens: slow and expensive.
This is why many users keep assets on exchanges despite "not your keys, not your coins." Exchanges handle the expensive writes internally. Users see balances instantly.
Token Metadata: More Than Just Balances
Tokens aren't just numbers. Most include metadata defining their identity.
ERC-20 standard requires:
name: The token's full name ("USD Coin")symbol: The trading ticker ("USDC")decimals: How divisible the token is (6 for USDC, 18 for most tokens)
This metadata lives in contract storage and never changes after deployment. It tells wallets and exchanges how to display the token. USDC with 6 decimals means 1,000,000 raw units equals 1.00 USDC. Your wallet divides by 10^6 to show the human-readable amount.
NFTs extend this concept dramatically. ERC-721 tokens include a tokenURI pointing to JSON metadata describing each unique token. This metadata contains the image URL, traits, description, and properties that make the NFT valuable [13]. The token itself is just an ID number. The metadata makes it art.
Contracts can make metadata mutable or immutable. CryptoPunks metadata lives entirely on-chain, unchangeable forever [14]. Most NFT metadata lives on IPFS or centralized servers. If servers go offline, images disappear.
Understanding this distinction matters when evaluating long-term NFT value.
Composability: Tokens as Building Blocks
The real power emerges when tokens interact with other contracts.
A single DeFi transaction might:
Approve a token for spending (write operation)
Swap tokens on Uniswap (writes to multiple token contracts)
Deposit resulting tokens into a yield vault (more writes)
Receive vault shares representing your deposit (token creation)
Each step uses standardized token interfaces. Uniswap doesn't need custom code for your token. The yield vault doesn't need to understand Uniswap. They just call the same standard functions. Everything works.
This composability creates the "money legos" that make DeFi possible. Developers combine existing protocols like puzzle pieces. Aave lending + Curve trading + Convex yield optimization = a complete DeFi strategy executed in one transaction [15].
The same mechanisms that move simple tokens also power complex financial instruments. That's the elegance of token standards. Simple primitives enabling sophisticated systems.
Why These Mechanics Matter
Understanding token mechanics at this level changes how you interact with Web3. You'll understand why gas costs vary wildly. You'll recognize when a protocol asking for unlimited approval is risky. You'll grasp why some tokens work instantly while others take minutes. You'll see how smart contract exploits steal funds by manipulating these basic operations.
Token mechanics aren't abstract computer science. They're the foundation for how value moves in digital economies.
Master these basics, and the rest of the ecosystem makes sense. With the core mechanics clear, we can explore how these tokens get created in the first place, the role of smart contracts in defining and deploying token systems.
References
[1] Ethereum Nodes - https://etherscan.io/nodetracker
[2] Ethereum Transaction Lifecycle - https://ethereum.org/en/developers/docs/transactions/
[3] Ethereum Average Block Time - https://ycharts.com/indicators/ethereum_average_block_time
[4] Solana Transaction Speed - https://solana.com/news/validator-health-report-august-2023
[5] Ethereum Gas Tracker - https://etherscan.io/gastracker
[6] Compound Protocol Documentation - https://docs.compound.finance/
[7] Token Approval Risks - https://kalis.me/unlimited-erc20-allowances/
[8] Revoke.cash - https://revoke.cash/
[9] Ethereum Gas Price History - https://ethereumprice.org/gas/
[10] L2 Fees Comparison - https://l2fees.info/
[11] Solana Performance - https://solana.com/news/solana-economic-design-overview
[12] Uniswap v2 Core - https://docs.uniswap.org/contracts/v2/concepts/core-concepts/swaps
[13] ERC-721 Token Standard - https://eips.ethereum.org/EIPS/eip-721
[14] CryptoPunks - https://www.larvalabs.com/cryptopunks
[15] DeFi Composability - https://chain.link/education-hub/defi-composability
Last updated