IndexCrypto
Educational only. Not financial, tax or legal advice, and nothing here is a recommendation to buy anything.

How ERC-20 Tokens Work: Balances, Approvals, and Fees

ERC-20 tokens live in a contract, not in your wallet. How transfer, approve, and transferFrom work, why gas is paid in the native coin, and what approvals expose.

An ERC-20 token is not a thing that sits in a wallet. It is a number recorded inside a smart contract, and the wallet is a window onto that number. Everything that surprises people about ERC-20 tokens follows from that one fact: why a token can vanish from a wallet interface while still existing on-chain, why sending a token costs the chain’s native coin rather than the token itself, and why a signature that says nothing about moving funds can still empty an address.

The standard itself is small. It defines a fixed list of functions that a token contract must expose so that wallets, exchanges and other contracts can treat every compliant token the same way. The functions are the whole interface; the behaviour behind them is written by whoever deployed the contract, which is why two tokens with identical names can behave nothing alike.

What the ERC-20 interface actually defines

The standard specifies functions and events. The ones a holder meets, directly or through a wallet, are these:

FunctionWhat it reports or doesWhat it does not do
balanceOf(address)Returns the token balance recorded for that address inside the contractDoes not prove the address controls a key, and does not move anything
transfer(to, amount)Moves amount from the caller’s recorded balance to toDoes not move tokens the caller was approved to spend on someone else’s behalf
approve(spender, amount)Records that spender may move up to amount of the caller’s tokensDoes not move any tokens at the moment of approval
allowance(owner, spender)Returns how much spender is still permitted to move from ownerDoes not change the permission
transferFrom(from, to, amount)Moves tokens from from to to, drawing down the caller’s allowanceCannot exceed the remaining allowance

There are also totalSupply(), and the Transfer and Approval events that indexers and wallets read to build a history. The events are how a block explorer shows a token movement; the balance itself is always the contract’s stored number.

A wallet does not hold tokens. It holds keys, derives an address, and asks each token contract what balanceOf returns for that address. If a wallet does not know about a token contract, it shows nothing even though the balance exists. Adding a token to a wallet is telling the interface which contract to query, not importing the tokens.

Why a token balance is a row in a contract

When a token is deployed, the contract is given storage. Each holder’s balance is a value in that storage, keyed by address. A transfer is a state change: the contract subtracts from one row and adds to another. There is no separate ledger per wallet and no file that travels with the token.

This has consequences a reader can use to predict behaviour. If a contract’s code has a flaw or a privileged function that can rewrite balances, the balance a wallet displays is only as reliable as that code. If a token contract is upgraded or replaced, the old contract’s balances stay where they are. And if two tokens share a name and symbol, the wallet may display them identically while they are entirely separate contracts with separate balances.

Anyone can deploy a contract that implements the interface and calls itself by any name. The name and symbol are strings chosen by the deployer. A familiar name on a token is not evidence of anything; the contract address is the identifier that matters.

Gas is paid in the chain’s native coin, not the token

Every ERC-20 transfer, approval or swap is a transaction, and every transaction costs gas. Gas is priced and paid in the native coin of the chain the contract lives on. A token contract cannot pay its own gas, and holding a large token balance does not cover a transaction fee.

This is the source of the most common stuck-wallet situation: an address holds tokens but no native coin, so it can read balances but cannot send anything. The fix is to get a small amount of the native coin to that address, not more tokens.

The fee itself is estimated before signing, usually as a gas limit multiplied by a gas price or base fee. A wallet’s estimate can be wrong when the transaction does something more complex than a plain transfer, such as interacting with a contract that loops over many holders. If the estimate is too low the transaction reverts and the gas spent on the failed attempt is still consumed.

Approvals are a standing permission, and that is what drainers use

approve does not move tokens. It writes a permission: the named spender may call transferFrom on the owner’s balance up to the approved amount. Many applications ask for an approval as a separate transaction before the action the user intended, because the application needs to pull tokens in a later step.

An unlimited approval is a permission with no ceiling. It persists until it is changed or the allowance is used. If the spender contract is malicious, or a legitimate contract is later compromised, the permission is what allows tokens to be moved without any further signature from the owner. A drainer does not need a seed phrase when an outstanding allowance will do.

An approval request should be read as a question: which spender address, and how much. A request for an unlimited amount to an address that has no reason to hold that permission is the situation to decline. Reducing an allowance to zero, or to the exact amount needed, limits what a later failure can cost. The mechanics of reviewing and revoking outstanding allowances are covered in token approvals.

A signature request is not always an approval. Some requests are permits, which grant an allowance by signature rather than by transaction, and some are transfers. The wallet’s display is the only place the distinction appears before signing, which is why the decoded details matter more than the site’s description of what it is asking for.

Reading a transaction before signing it

A wallet usually shows a summary. The summary is generated by the requesting site or by the wallet’s own decoder, and the two can disagree. The raw calldata is the authoritative record of what the transaction will do.

Foundry’s cast can decode calldata against a known function signature:

cast decode-calldata "approve(address,uint256)" 0x095ea7b3000000000000000000000000...

The output names the function and its arguments, so the spender address and the approved amount are visible rather than inferred from a summary. Source: https://getfoundry.sh/cast/reference/decode-calldata

When only the four-byte selector is known, it can be looked up:

cast 4byte 0x095ea7b3

The output lists known signatures matching that selector. A selector can match more than one signature, so the result narrows the possibilities rather than proving the function. Source: https://getfoundry.sh/cast/reference/4byte

To check what a contract records for an address, the function can be called directly against a node:

cast call <token-address> "balanceOf(address)(uint256)" <owner-address> --rpc-url <rpc-url>

The output is the balance the contract stores, which is the number a wallet should be displaying. A mismatch between this and the wallet’s figure points at the wallet’s token list, not at the chain.

Sending a token to the wrong network, and other irreversible outcomes

A token contract exists on one chain. The same project may deploy contracts at different addresses on several chains, and those are separate tokens with separate balances. Sending a token to an address on a different chain, or to a contract address that does not implement the receiving side, generally does not return the tokens. The transaction is final once included in a block.

Sending to a contract that is not designed to handle tokens can lock them. A plain transfer to a contract address credits that contract’s balance, and whether anything can move them afterwards depends on code the sender did not inspect. The network and address checks that prevent this are set out in sending crypto to the wrong network.

What the standard does not guarantee

The ERC-20 interface standardises how a token is called, not what it does when called. A contract can implement the functions and still include a fee taken on each transfer, a pause switch, a blocklist, a mint function, or a change to balances by an owner key. None of that violates the interface.

A token that takes a fee on transfer is a concrete example. The transfer call succeeds, the Transfer event may report the amount sent, but the recipient’s balance rises by less. A wallet’s estimate of what will arrive can be wrong for this reason, and a contract that forwards tokens can fail if it does not account for the deduction.

Because the interface says nothing about supply, issuance or control, the questions that matter about a specific token are answered by its contract and its deployment history, not by the fact that it is ERC-20 compliant. Compliance is a compatibility claim, not a safety claim.

Where the token standard ends and the chain begins

ERC-20 is a convention for one chain family. The balance, the gas, the finality and the approval model all belong to the underlying chain. A reader who understands that a balance is a contract’s stored number, that gas is paid in the native coin, and that an approval is a standing permission can predict what will happen in situations this page has not described: why a swap fails with plenty of the token but no native coin, why a revoked approval stops a drainer, why a copied token name proves nothing, and why a transaction that has been included cannot be talked back out of.

Common questions

Why does my wallet show a token balance but I can't send it?

The balance is read from the token contract, but sending requires a transaction, and transactions cost gas paid in the chain's native coin. If the address holds no native coin, the wallet can display the token but cannot broadcast a transfer. Sending a small amount of the native coin to that address resolves it.

What does an ERC-20 approval actually let a site do?

It records a permission in the token contract allowing a named spender address to move up to a set amount of your tokens using transferFrom. No tokens move at the moment of approval. The permission remains until it is used, reduced or revoked, which is why an unlimited approval to an unfamiliar address is worth declining.

Is an ERC-20 token the same as the coin I pay fees with?

No. The native coin of the chain pays for gas and is not an ERC-20 token. An ERC-20 token is a separate contract whose balances are recorded inside it. Holding the token does not provide the native coin needed to move it.

Why do two tokens with the same name have different addresses?

The name and symbol are strings chosen by whoever deployed the contract, and anyone can deploy a contract using any name. Each deployment is a separate contract with its own balances. The contract address is the only reliable identifier, not the name shown in a wallet.

Can a token take a fee when I transfer it?

Yes. The ERC-20 interface fixes how functions are called, not what they do internally. A contract can deduct an amount on each transfer, so the recipient receives less than the amount sent even though the transaction succeeds. The contract's code and its transfer history show whether this happens.

Read next