A lightweight ERC20-style token implementation using Foundry. This token supports minting, burning, transferring, approving, and allowance-based transactions. Built without OpenZeppelin to help understand the mechanics of ERC20 from scratch.
- ✅ Mint on deploy (constructor initializes total supply)
- ✅ Basic transfers
- ✅
approve
/transferFrom
mechanism - ✅
approveAndCall
external interaction - ✅ Burn tokens (
burn
,burnFrom
) - ✅ Events:
Transfer
,Approval
,Burn
Property | Type | Description |
---|---|---|
name |
string |
Token name (set in constructor) |
symbol |
string |
Token symbol (set in constructor) |
decimals |
uint8 |
Always 18 — standard ERC20 format |
totalSupply |
uint256 |
Total supply of tokens |
balanceOf |
mapping |
Tracks balances of each address |
allowance |
mapping |
Approved spending limits |
transfer(address to, uint256 value)
: Send tokens to another address.approve(address spender, uint256 value)
: Approve a spender to use your tokens.transferFrom(address from, address to, uint256 value)
: Transfer on behalf of another address.burn(uint256 value)
: Destroy your own tokens.burnFrom(address from, uint256 value)
: Destroy tokens from another address using allowance.approveAndCall(address spender, uint256 value, bytes calldata extraData)
: Approve and trigger callback on external contract.
$ forge build
$ forge test
$ forge fmt
$ forge snapshot
$ anvil
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
$ cast <subcommand>
$ forge --help
$ anvil --help
$ cast --help