hoelee d963f76122
Some checks failed
CI / Foundry project (push) Has been cancelled
Rewrite README as ERC-20 learning notes
2026-08-19 19:50:10 +08:00
2024-08-17 14:16:44 +08:00
2024-08-18 06:16:46 +08:00
2024-08-17 14:16:44 +08:00
2024-08-17 14:16:44 +08:00
2024-08-17 14:16:44 +08:00
2024-08-17 14:16:44 +08:00
2024-08-18 06:16:46 +08:00
2024-08-17 14:16:44 +08:00

Foundry ERC-20 — Learning Notes

A learning project for writing an ERC-20 token with Foundry. This repo is my own notes-on-the-way — expect experiments, scaffolding, and takeaways, not a finished production token.

Status: early scaffold. The Counter example has been kept as-is while I set up the project structure and Foundry toolchain; the ERC-20 implementation is next.

Why this exists

I'm moving from traditional web development into Web3 / smart contract development. Foundry is the toolchain I chose to learn Solidity testing and deployment properly. This repo is where I keep the lessons as I go, so I can revisit them and so each commit shows what I actually learned (not what I'd like people to think I know).

What Foundry gives you

Foundry is a fast, portable, modular EVM development toolkit written in Rust:

  • Forge — the testing framework (like Truffle / Hardhat / DappTools).
  • Cast — a Swiss-army knife for talking to contracts, sending transactions, reading chain data.
  • Anvil — a local Ethereum node for testing (like Ganache / Hardhat Network).
  • Chisel — a fast Solidity REPL for trying snippets quickly.

Project layout

├── lib/       # dependencies (forge-std, openzeppelin-contracts)
├── script/    # deployment scripts
├── src/       # contracts
├── test/      # tests
└── foundry.toml

Dependencies are pulled in as git submodules. OpenZeppelin is included because its ERC20 base is what most real tokens build on — rather than reimplementing the standard from scratch (and getting the edge cases wrong).

Learning plan

  1. Scaffold — get Foundry building / testing the default Counter example.
  2. Dependencies — wire up forge-std + OpenZeppelin as submodules.
  3. ERC-20 token — inherit OpenZeppelin's ERC20, learn the constructor, minting, decimals.
  4. Tests — unit tests + fuzz tests for the token (balance, transfer, allowance).
  5. Deploy script — a repeatable deploy against a local Anvil chain.

Usage

# build
forge build

# test
forge test

# format
forge fmt

# gas snapshots
forge snapshot

# local node
anvil

# deploy (example — replace with your RPC URL / key)
forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>

# interact with the chain
cast <subcommand>

Documentation

Description
Learning project: an ERC-20 token built with Foundry (scaffold + OpenZeppelin).
Readme 29 KiB
Languages
Gerber Image 100%