Sub topic 5
Native Coins and Tokens
Assume you understand wallets, addresses, and basic blockchain transactions. This chapter focuses on account-based networks such as Ethereum and explains how native coins differ from tokens created by smart contracts.
Two different kinds of assets
A native coin is the asset built into a blockchain. Ether (ETH) belongs to Ethereum. MATIC belongs to Polygon. The network itself tracks native-coin balances, and its protocol uses the coin to pay transaction fees.
A token is an asset managed by a smart contract on a blockchain. An ERC-20 token on Ethereum is not a separate blockchain. Its contract stores balances and applies rules for transfers, minting, and burning. USDC and many other assets use this model.
| Property | Native coin | Token |
|---|---|---|
| Managed by | Blockchain protocol | Smart contract |
| Example | ETH on Ethereum | USDC on Ethereum |
| Transfer action | Native transaction | Contract function call |
| Gas payment | Native coin | Usually still the native coin |
| Balance location | Account state | Token contract storage |
The same symbol can exist on multiple networks. USDC on Ethereum and USDC on an Ethereum-compatible sidechain may have different contract addresses and transfer costs. Always identify the network and the token contract, not only the asset name.
What happens during a transfer
A native-coin transfer changes the sender and recipient account balances. The transaction includes a recipient address and a value denominated in the coin's smallest unit, such as wei for ETH.
A token transfer calls the token contract's transfer function. The contract subtracts units from the sender's token balance and adds them to the recipient's balance. The native coin is still needed to pay gas for this contract execution.
For example, sending 5 USDC requires enough ETH for gas on Ethereum. Holding 5 USDC alone does not let the wallet submit the transaction. On another network, the required gas coin may be a different native asset.
Amounts and decimals
User interfaces display readable amounts such as 5.25, but contracts use integer base units. A token with 6 decimals represents 5.25 tokens as 5,250,000 base units. A token with 18 decimals represents the same display amount as 5,250,000,000,000,000,000 base units.
Read the token's decimals() value before constructing an amount. Do not use ordinary JavaScript floating-point arithmetic for money. Use a decimal conversion function that produces an integer.
import { JsonRpcProvider, Wallet, Contract, parseUnits } from "ethers";
const provider = new JsonRpcProvider(process.env.RPC_URL);
const wallet = new Wallet(process.env.PRIVATE_KEY, provider);
const token = new Contract(process.env.TOKEN_ADDRESS, [
"function decimals() view returns (uint8)",
"function transfer(address to, uint256 amount) returns (bool)",
], wallet);
const decimals = await token.decimals();
const amount = parseUnits("5.25", decimals);
const tx = await token.transfer(process.env.RECIPIENT, amount);
await tx.wait();
console.log("Token transfer confirmed:", tx.hash);Practical checks
Before sending either asset:
- Confirm the network selected by both parties.
- Verify the recipient address through a trusted channel.
- Check that the asset contract address is correct.
- Keep enough native coin for gas.
- Send a small test amount when the transfer is unfamiliar.
Exercise
You want to send 10 tokens on a network, but your wallet holds only those tokens and no native coin. What is missing?
Show answer
You need enough of the network's native coin to pay gas for the token contract call.