Rewrite README as ERC-20 learning notes
Some checks failed
CI / Foundry project (push) Has been cancelled
Some checks failed
CI / Foundry project (push) Has been cancelled
This commit is contained in:
118
README.md
118
README.md
@@ -1,66 +1,76 @@
|
||||
## Foundry
|
||||
# Foundry ERC-20 — Learning Notes
|
||||
|
||||
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
|
||||
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.
|
||||
|
||||
Foundry consists of:
|
||||
> **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.
|
||||
|
||||
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
|
||||
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
|
||||
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
|
||||
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
|
||||
## Why this exists
|
||||
|
||||
## Documentation
|
||||
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).
|
||||
|
||||
https://book.getfoundry.sh/
|
||||
## 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
|
||||
|
||||
```shell
|
||||
$ forge build
|
||||
# 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>
|
||||
```
|
||||
|
||||
### Test
|
||||
## Documentation
|
||||
|
||||
```shell
|
||||
$ forge test
|
||||
```
|
||||
|
||||
### Format
|
||||
|
||||
```shell
|
||||
$ forge fmt
|
||||
```
|
||||
|
||||
### Gas Snapshots
|
||||
|
||||
```shell
|
||||
$ forge snapshot
|
||||
```
|
||||
|
||||
### Anvil
|
||||
|
||||
```shell
|
||||
$ anvil
|
||||
```
|
||||
|
||||
### Deploy
|
||||
|
||||
```shell
|
||||
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
|
||||
```
|
||||
|
||||
### Cast
|
||||
|
||||
```shell
|
||||
$ cast <subcommand>
|
||||
```
|
||||
|
||||
### Help
|
||||
|
||||
```shell
|
||||
$ forge --help
|
||||
$ anvil --help
|
||||
$ cast --help
|
||||
```
|
||||
- Foundry book: https://book.getfoundry.sh/
|
||||
- OpenZeppelin ERC-20: https://docs.openzeppelin.com/contracts/4.x/erc20
|
||||
|
||||
Reference in New Issue
Block a user