Skip to content

Commit 4a37ff9

Browse files
committed
readme updated
1 parent e14847c commit 4a37ff9

1 file changed

Lines changed: 176 additions & 55 deletions

File tree

README.md

Lines changed: 176 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<<<<<<< HEAD
21
# CodesenSys ERC20 Implementation (Foundry | Solady)
32

4-
A production-grade, security-first ERC20 token implementation built by **CodesenSys** using **Foundry**.
5-
This repository is not a toy example. It is designed as a **reference-grade, extensible, auditable ERC20 codebase** suitable for real-world deployments.
3+
A production-grade, security-first ERC20 token implementation built by **CodesenSys** using **Foundry** and **Solady**.
4+
It is designed as a **reference-grade, extensible, auditable ERC20 codebase** suitable for real-world deployments.
65

76
The focus is on:
7+
88
- Correctness
99
- Security
1010
- Gas efficiency
@@ -16,24 +16,33 @@ The focus is on:
1616

1717
## Why This Repository Exists
1818

19-
Most ERC20 examples stop at it compiles and transfers tokens.
19+
Most ERC20 examples stop at "it compiles and transfers tokens".
2020

2121
This implementation goes further:
2222

2323
- Models **real production concerns**
2424
- Enforces **strict invariants**
25-
- Uses **Foundrys testing, fuzzing, and tooling**
25+
- Uses **Foundry's testing, fuzzing, and tooling**
2626
- Separates **business logic from mechanics**
2727
- Documents **design decisions explicitly**
2828
- Provides a **clean base for further token systems** (vesting, staking, governance, bridges, etc.)
2929

3030
This is intended to be:
31+
3132
- A **starting point for serious token projects**
3233
- A **learning reference for professional Solidity engineers**
3334
- A **baseline for audits and production deployments**
3435

3536
---
3637

38+
## Built With
39+
40+
- **[Foundry](https://book.getfoundry.sh/)** - Blazing fast, portable and modular toolkit for Ethereum application development
41+
- **[Solady](https://github.com/Vectorized/solady)** - Gas-optimized Solidity libraries by Vectorized
42+
- Core ERC20 implementation inherits from Solady's highly optimized contracts
43+
44+
---
45+
3746
## Architecture Overview
3847

3948
The system is structured around:
@@ -51,6 +60,7 @@ The system is structured around:
5160
- Policy layers (who can mint, burn, pause, etc.)
5261

5362
Design goals:
63+
5464
- Predictable storage layout
5565
- Minimal branching in hot paths
5666
- Explicit revert reasons
@@ -89,19 +99,25 @@ Design goals:
8999
## Engineering Principles
90100

91101
### 1. Correctness Over Convenience
102+
92103
Every state mutation is explicit. No hidden side effects. No magical flows.
93104

94105
### 2. Invariants First
106+
95107
The implementation is written around invariants:
108+
96109
- Sum of balances == totalSupply
97110
- Transfers do not create or destroy value
98111
- Mint and burn are the only supply-changing operations
99112

100113
### 3. Minimal Surface Area
114+
101115
No unnecessary features in the core layer. Policy features (roles, caps, pauses, etc.) are intended to be layered on top.
102116

103117
### 4. Audit-First Design
118+
104119
The code is structured to be:
120+
105121
- Readable
106122
- Traceable
107123
- Verifiable
@@ -119,6 +135,7 @@ This repository uses Foundry for:
119135
- Gas profiling
120136

121137
Test categories include:
138+
122139
- Transfer correctness
123140
- Allowance behavior
124141
- Mint/Burn supply invariants
@@ -133,102 +150,206 @@ Test categories include:
133150
- Randomized mint/burn operations
134151

135152
This ensures:
153+
136154
- No silent balance corruption
137155
- No supply drift
138156
- No allowance desync
139157

140158
---
141159

142160
## Project Structure
143-
src/<br />
144-
├── ERC20.sol # Core ERC20 implementation<br />
145-
├── interfaces/<br />
146-
│ └── IERC20.sol # ERC20 interface<br />
147-
└── extensions/ # Future extensions (cap, roles, etc<br />
148-
<br />
149-
test/<br />
150-
├── ERC20.t.sol # Unit tests<br />
151-
├── ERC20.fuzz.t.sol # Fuzz tests<br />
152-
└── ERC20.invariant.t.sol# Invariant tests<br />
153-
<br />
154-
##Extending This Implementation
161+
162+
```
163+
src/
164+
├── ERC20.sol # Core ERC20 implementation
165+
├── interfaces/
166+
│ └── IERC20.sol # ERC20 interface
167+
└── extensions/ # Future extensions (cap, roles, etc.)
168+
169+
test/
170+
├── ERC20.t.sol # Unit tests
171+
├── ERC20.fuzz.t.sol # Fuzz tests
172+
└── ERC20.invariant.t.sol # Invariant tests
173+
```
174+
175+
---
176+
177+
## Extending This Implementation
155178

156179
This base is intentionally clean and minimal.
180+
157181
It is designed to be extended with:
158-
Capped supply
159-
Role-based minting
160-
Pausable transfers
161-
Vesting systems
162-
Staking systems
163-
Governance voting power
164-
Bridging adapters
165-
Upgradeable proxies
182+
183+
- Capped supply
184+
- Role-based minting
185+
- Pausable transfers
186+
- Vesting systems
187+
- Staking systems
188+
- Governance voting power
189+
- Bridging adapters
190+
- Upgradeable proxies
191+
166192
Without modifying the core accounting engine.
167-
=======
168-
## Foundry
169193

170-
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
194+
---
171195

172-
Foundry consists of:
196+
## Getting Started
173197

174-
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
175-
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
176-
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
177-
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
198+
### Prerequisites
178199

179-
## Documentation
200+
- [Foundry](https://book.getfoundry.sh/getting-started/installation)
180201

181-
https://book.getfoundry.sh/
202+
### Installation
182203

183-
## Usage
204+
```shell
205+
# Clone the repository
206+
git clone https://github.com/CodesenSys/erc20-implementation.git
207+
cd erc20-implementation
208+
209+
# Install dependencies
210+
forge install
211+
```
184212

185213
### Build
186214

187215
```shell
188-
$ forge build
216+
forge build
189217
```
190218

191219
### Test
192220

193221
```shell
194-
$ forge test
222+
# Run all tests
223+
forge test
224+
225+
# Run tests with gas reporting
226+
forge test --gas-report
227+
228+
# Run specific test file
229+
forge test --match-path test/ERC20.t.sol
230+
231+
# Run with verbosity
232+
forge test -vvv
195233
```
196234

197235
### Format
198236

199237
```shell
200-
$ forge fmt
238+
forge fmt
201239
```
202240

203241
### Gas Snapshots
204242

205243
```shell
206-
$ forge snapshot
244+
forge snapshot
207245
```
208246

209-
### Anvil
247+
### Deploy
210248

211249
```shell
212-
$ anvil
250+
forge script script/Deploy.s.sol:DeployScript --rpc-url <your_rpc_url> --private-key <your_private_key>
213251
```
214252

215-
### Deploy
253+
---
216254

217-
```shell
218-
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
219-
```
255+
## Foundry Toolkit
220256

221-
### Cast
257+
**Foundry** consists of:
222258

223-
```shell
224-
$ cast <subcommand>
225-
```
259+
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools)
260+
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data
261+
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network
262+
- **Chisel**: Fast, utilitarian, and verbose solidity REPL
226263

227-
### Help
264+
### Useful Commands
228265

229266
```shell
230-
$ forge --help
231-
$ anvil --help
232-
$ cast --help
267+
# Get help
268+
forge --help
269+
anvil --help
270+
cast --help
271+
272+
# Start local node
273+
anvil
274+
275+
# Interact with contracts
276+
cast <subcommand>
233277
```
234-
>>>>>>> dev
278+
279+
For more details, see the [Foundry Book](https://book.getfoundry.sh/).
280+
281+
---
282+
283+
## Security Considerations
284+
285+
This implementation follows security best practices:
286+
287+
- ✅ Uses Solidity ^0.8 for built-in overflow protection
288+
- ✅ Inherits from battle-tested Solady libraries
289+
- ✅ Extensive test coverage including fuzz and invariant tests
290+
- ✅ Explicit error handling with custom errors
291+
- ✅ Zero address checks on critical operations
292+
- ✅ Follows checks-effects-interactions pattern
293+
294+
**However**, before deploying to production:
295+
296+
- Conduct a professional security audit
297+
- Review all extension/policy layers added on top
298+
- Test thoroughly on testnets
299+
- Consider formal verification for high-value deployments
300+
301+
---
302+
303+
## Contributing
304+
305+
Contributions are welcome! Please:
306+
307+
1. Fork the repository
308+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
309+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
310+
4. Push to the branch (`git push origin feature/amazing-feature`)
311+
5. Open a Pull Request
312+
313+
Please ensure:
314+
315+
- All tests pass
316+
- Code is formatted with `forge fmt`
317+
- New features include tests
318+
- Documentation is updated
319+
320+
---
321+
322+
## License & Attribution
323+
324+
This project is licensed under the MIT License
325+
326+
### Third-Party Dependencies
327+
328+
This implementation builds upon:
329+
330+
- **[Solady](https://github.com/Vectorized/solady)** by Vectorized
331+
Licensed under the MIT License
332+
Copyright (c) 2022 Solady Contributors
333+
334+
Special thanks to the Solady team for their highly optimized and gas-efficient Solidity libraries.
335+
336+
---
337+
338+
## Disclaimer
339+
340+
This software is provided "as is", without warranty of any kind. Use at your own risk. Always conduct thorough testing and professional audits before deploying to production environments.
341+
342+
---
343+
344+
## Contact
345+
346+
**CodesenSys**
347+
348+
- GitHub: [@CodesenSys](https://github.com/CodesenSys)
349+
- Website: [codesensys.com](https://codesensys.com)
350+
351+
For questions or support, please open an issue on GitHub.
352+
353+
---
354+
355+
Built with ❤️ by CodesenSys

0 commit comments

Comments
 (0)