Sub topic 1
Coins and Tokens: What a Token Actually Is
Prerequisites
This chapter assumes you already know the following:
- What a blockchain is, and that a wallet is a pair of keys that controls an address.
- What a smart contract is: code deployed at an address that runs when a transaction calls it.
- How to read a short Solidity or Python snippet.
You do not need to know any token standard yet. Chapter 2 covers ERC-20 in detail. This chapter builds the mental model that the rest of the tutorial relies on.
The core distinction
People use "coin" and "token" loosely, and many exchanges list both under "crypto." The technical difference is where the asset's records live.
- A coin (also called a native asset) is built into a blockchain's protocol. Ether on Ethereum, bitcoin on Bitcoin and SOL on Solana are examples. The protocol itself creates the coin, tracks balances, and requires it to pay transaction fees.
- A token is an asset created by a smart contract that runs on top of an existing blockchain. The blockchain does not know the token exists. Only the contract knows, and the contract is just code with storage.
Here is the sentence to remember: a coin is a balance the protocol keeps, and a token is a balance a contract keeps.
| Property | Coin (native asset) | Token (contract-based) |
|---|---|---|
| Where balances are stored | In the protocol's account state | In the token contract's storage |
| Who creates it | The protocol, through block rewards or genesis allocation | Anyone who deploys a contract |
| Pays network fees | Yes | No, unless the chain supports it through extra mechanisms |
| Rules for transfers | Fixed by the protocol | Defined by the contract's code |
| Can be changed after launch | Only by a network upgrade | Depends on the contract, for example an owner role or an upgradeable proxy |
The last two rows matter most for the later chapters. A coin follows the same transfer rules everywhere. A token follows whatever its author wrote, so you must read or trust that code.
A token is a ledger inside a contract
A token contract does not hold coins in a wallet-like way that the chain can inspect. At its core, it holds a table that maps addresses to numbers.
class ToyToken:
"""A minimal in-memory model of what a token contract stores."""
def __init__(self, supply, creator):
self.balances = {creator: supply}
self.total_supply = supply
def balance_of(self, owner):
return self.balances.get(owner, 0)
def transfer(self, sender, recipient, amount):
if self.balance_of(sender) < amount:
raise ValueError("insufficient balance")
self.balances[sender] -= amount
self.balances[recipient] = self.balance_of(recipient) + amount
token = ToyToken(1_000, "alice")
token.transfer("alice", "bob", 250)
print(token.balance_of("alice"), token.balance_of("bob"))
print(sum(token.balances.values()) == token.total_supply)Running this prints 750 250 and then True. Four facts follow from this model.
- "Owning" a token means a number in a table. Your wallet does not store tokens. It stores the key that is allowed to ask the contract to change your entry.
- Transfers are function calls. Sending a token is a transaction that calls
transferon the token contract. The sender pays gas in the chain's native coin, not in the token. - The contract can enforce any rule. A transfer could be blocked for some addresses, taxed, paused, or limited per day. The code decides.
- Supply is whatever the code says. A contract can mint a fixed amount once, mint continuously, or let an owner mint at will.
The Solidity example from the plan shows the common shape. It mints the whole supply to the deployer in the constructor and has no way to create more.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MemeToken is ERC20 {
constructor() ERC20("Meme Token", "MEME") {
_mint(msg.sender, 1_000_000_000 * 10 ** decimals());
}
}The contract fixes the supply at one billion units. It says nothing about who holds those units after deployment, or whether anyone has promised to keep trading liquidity available. Those facts live outside this code, and later chapters return to them.
Why you pay gas in the coin
Suppose you send 100 tokens on Ethereum. The transaction is addressed to the token contract, and it asks the contract to run transfer. Validators execute that code and charge for the computation in ether, because the protocol only understands its own coin.
The sequence below shows who talks to whom.
This is why a wallet with 5,000 tokens and zero ether cannot send them. It cannot pay for the call. It is also why a token's value and the native coin's value are separate things. The token can lose most of its value while the chain keeps working.
What a token can represent
Because a token is just a record with rules attached, it can stand for many different things. The chain does not enforce any of these meanings. They come from the project's design and from what people agree to treat as valuable.
- A currency or unit of account, such as a stablecoin pegged to a dollar.
- Access or a payment right, such as the right to use a service or pay a reduced fee.
- A vote, where balance determines influence over a protocol.
- A claim on an off-chain or on-chain asset, such as a wrapped coin or a receipt for deposited funds.
- A collectible with no function, which is the idea behind memecoins.
The tutorial focuses on three of these: utility tokens, governance tokens, and memecoins. Notice that all three can be implemented with the same contract skeleton. The difference between them is mostly about what people expect the token to do and why they want it, not about the code. Chapter 3 returns to this overlap.
Fungible and non-fungible tokens
A token is fungible when every unit is interchangeable with every other unit, like one dollar bill for another. The balance table above is fungible. It stores only an amount per address, so no unit has an identity.
A non-fungible token (NFT) tracks individual items instead, usually by mapping a unique ID to an owner. This tutorial deals only with fungible tokens. All three categories you will study use the fungible model.
Common errors and edge cases
Most beginners' mistakes at this level come from forgetting that a token is only a contract.
- Confusing a token with its network. A token named "Meme Token" on Ethereum is not the same asset as a token with the same name on another chain. Each deployment is a different contract at a different address. Always identify a token by chain and contract address, not by name or ticker.
- Trusting the ticker. Anyone can deploy a contract with the symbol "USDC" or any other name. The ticker is a text field in the contract. Only the address identifies the real one.
- Assuming balances are stored in your wallet. If you lose a device but keep your keys, the balances are still in the contract. If the contract has a bug or an administrator can alter balances, your keys do not protect you.
- Forgetting decimals. Contracts store integers. A token with 18 decimals stores one whole token as 10^18 base units, which is why the Solidity example multiplies by
10 ** decimals(). Mixing up units causes errors of many orders of magnitude. - Assuming immutability. A contract can be upgradeable, or can include an owner function to mint, pause, or blacklist addresses. Whether anyone has that power is a property of the code, so check it.
- Sending to the wrong place. Sending tokens to a contract that has no way to send them out locks them permanently, because the token contract only records the new balance.
Why this matters for the rest of the tutorial
Every later chapter depends on the idea that a token's behavior comes from code plus the choices of the people who control it.
- Standards such as ERC-20 give wallets and exchanges a common set of functions to call, so they can support thousands of tokens without custom code.
- Supply and allocation decide who holds the table's entries at the start.
- Governance features add vote tracking to the same table.
- Liquidity pools turn the table's entries into something tradeable at a price.
- Risks such as rug pulls come from the powers a deployer keeps, or from how liquidity is held.
When you meet an unfamiliar token, begin with three questions. Which chain and address does it live at? What does the contract allow, including minting, pausing, and changing rules? Who holds the balances?
Check your understanding
Exercise
A wallet holds 2,000 units of an ERC-20 token and 0 ether. The owner tries to send 500 tokens to a friend on Ethereum, and the transaction fails before it is sent. Explain why, and describe what the token contract's storage looks like before and after a successful transfer.
Show answer
The transfer is a call to the token contract, and the network charges gas in its native coin, ether. With 0 ether the wallet cannot pay for the call, so the transaction cannot be submitted. Before a successful transfer the contract's balance table has the sender at 2,000. After it, the sender is at 1,500 and the friend is at 500. The total supply is unchanged, and no coins or tokens move between wallets, only entries in the table change.
Exercise
Two contracts on different chains both have the name "Meme Token" and the symbol "MEME". How can you tell whether they are the same asset, and why is the ticker not enough?
Show answer
They are not the same asset by default. Each deployment is a separate contract with its own balance table, identified by chain plus contract address. The name and symbol are just text fields that any deployer can set, so only the chain and address, checked against an official source, identify a specific token.