ERC20 Token Standard: How It Works and What It Costs
ERC20 defines six functions and two events that make tokens on Ethereum interchangeable. How to deploy one, pay gas, read balances and send tokens by API.
Reviewed by Maurice Sobiera
ERC20 is the technical standard for fungible tokens on Ethereum, defined in EIP-20. It specifies the functions a token contract must expose to move tokens and read balances, plus two events. Because every ERC20 contract has the same interface, wallets, exchanges and APIs can handle any token without custom code.
What is ERC20?
An ERC20 token is a smart contract that keeps a table of balances. The standard fixes the interface to that table:
| Function or event | Purpose |
|---|---|
totalSupply() | Total number of tokens in existence |
balanceOf(owner) | Balance of one address |
transfer(to, value) | Move tokens from the caller to another address |
approve(spender, value) | Let another address spend up to value of the caller’s tokens |
allowance(owner, spender) | Remaining amount a spender may still use |
transferFrom(from, to, value) | Move tokens on behalf of an owner, within the allowance |
Transfer event | Emitted on every movement, including mints |
Approval event | Emitted when an allowance is set |
The name, symbol and decimals fields are optional in EIP-20, but nearly every token implements them. decimals matters in practice: a balance of 1000000 with 6 decimals is 1 token, not one million. The Ethereum developer documentation walks through the interface in more detail.
How do you create an ERC20 token?
You write a smart contract that implements the interface above, compile it and deploy the bytecode to Ethereum. The web-based compiler Remix can do the compile and deploy steps. For the contract itself, most projects start from a maintained implementation such as OpenZeppelin’s ERC20 instead of writing it from scratch. A ConsenSys reference implementation also exists. Once the deployment transaction is mined, the token exists and the new contract has an address.
What is the difference between ERC20 tokens and ETH?
ETH is the native currency of the Ethereum blockchain, tracked by the protocol itself. An ERC20 token is only a balance table inside a smart contract that runs on the Ethereum Virtual Machine. The protocol knows nothing about the token. A standard interface is what lets wallets and exchanges treat all such contracts the same way.
Can you pay gas fees with ERC20 tokens?
No. Gas is always paid in ETH, even when the transaction only moves ERC20 tokens. An address that holds 1,000 USDT but no ETH cannot send them. A token transfer also executes contract code, so it uses more gas than the 21,000 units of a plain ETH transfer. The Ethereum gas documentation explains how base fee and priority fee add up.
How much does it cost to create an ERC20 token?
Deploying costs gas, and the amount depends on contract size and the gas price at the time. Gas used multiplied by gas price gives the fee in ETH. You can read the current price on the Etherscan gas tracker. A minimal token contract is cheap to deploy compared to one with many extra features, because every byte of bytecode is paid for. If a developer or agency writes the contract, ask for a quote that lists their fee separately from the deployment gas. Auditing is a separate cost and not part of deployment.
Are ERC20 tokens legal?
It depends on the use and on the country. In most countries holding an ERC20 token is legal. Selling tokens, accepting them as payment or issuing them as company shares can require licenses, and taxes may apply. KYC and anti-money-laundering rules usually apply when you sell tokens to the public. Ask a lawyer who knows your jurisdiction before you launch. This article gives no legal advice.
What is a contract address?
A contract address is the address on the blockchain where the token contract lives. It is the only reliable identifier of a token. Names and symbols are not unique: anyone can deploy another contract called “USDT” with the same symbol, and only the contract address tells the two apart. Always copy the address from the issuer’s official page, then compare it on a block explorer such as Etherscan.
How do you send ERC20 tokens automatically?
Call the contract’s transfer function from a script instead of using a wallet interface. With the Chaingateway REST API you send one request per transfer and do not need to run a node or handle ABI encoding. The request needs the sending address, the recipient, the contract address of the token and the amount. If the sending wallet was created with a password, add password. For a wallet whose key you manage yourself, add privatekey.
curl -X POST https://app.chaingateway.io/api/v2/ethereum/transactions/erc20 \ -H "Authorization: Bearer $CHAINGATEWAY_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "from": "0xYourSenderAddress", "to": "0xRecipientAddress", "contractaddress": "0xTokenContractAddress", "amount": 100, "password": "your-wallet-password" }'A successful call returns status 201. If the sender holds too little ETH for gas, the API answers 422 with the node’s error message, for example insufficient funds for gas * price + value. To send to many recipients, loop over the list and send one request per recipient. You can set gas, gasprice, maxFeePerGas and maxPriorityFeePerGas yourself; see the API reference for all fields. The token is selected by contractaddress, so a new token needs no listing on our side.
How do you read an ERC20 balance?
You call balanceOf(address) on the token contract, or look the address up on a block explorer. Etherscan shows every token an address holds. For a payment flow you rarely need to poll balances. A webhook on the receiving address, with the token’s contract address as filter, sends your server a notification when a transfer arrives, so you can process deposits without polling. Failed notifications are not retried automatically. They show up in the failed-notifications list, and you can ask for a resend.
What other token standards are there?
ERC721 defines non-fungible tokens, where each token has a unique ID, and ERC1155 defines contracts that hold several token types at once. Both are specified as Ethereum Improvement Proposals: EIP-721 and EIP-1155.
Ready to build this yourself? Get your API key — 7-day trial, no card required — or see the Ethereum API for the full endpoint reference.