Token contracts track balances (state) of interchangeable assets.
The ERC-20 standard defines how these tokens behave, letting wallets and applications interact with them using consistent rules.
Paired with liquidity pools, tokens can be traded.
contract MyToken {
mapping(address => uint) public balanceOf;
uint public totalSupply;
string public symbol = "TKN";
function mint(address to, uint amount) public {
balanceOf[to] += amount;
totalSupply += amount;
}
function transfer(address to, uint amount) public {
require(balanceOf[msg.sender] >= amount, "Insufficient balance");
balanceOf[msg.sender] -= amount;
balanceOf[to] += amount;
}
}Mint Tokens
Transfer Tokens (selected sender = msg.sender)
Balances (state)