You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
6
5
7
6
The focus is on:
7
+
8
8
- Correctness
9
9
- Security
10
10
- Gas efficiency
@@ -16,24 +16,33 @@ The focus is on:
16
16
17
17
## Why This Repository Exists
18
18
19
-
Most ERC20 examples stop at “it compiles and transfers tokens”.
19
+
Most ERC20 examples stop at "it compiles and transfers tokens".
20
20
21
21
This implementation goes further:
22
22
23
23
- Models **real production concerns**
24
24
- Enforces **strict invariants**
25
-
- Uses **Foundry’s testing, fuzzing, and tooling**
25
+
- Uses **Foundry's testing, fuzzing, and tooling**
26
26
- Separates **business logic from mechanics**
27
27
- Documents **design decisions explicitly**
28
28
- Provides a **clean base for further token systems** (vesting, staking, governance, bridges, etc.)
29
29
30
30
This is intended to be:
31
+
31
32
- A **starting point for serious token projects**
32
33
- A **learning reference for professional Solidity engineers**
33
34
- A **baseline for audits and production deployments**
34
35
35
36
---
36
37
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
+
37
46
## Architecture Overview
38
47
39
48
The system is structured around:
@@ -51,6 +60,7 @@ The system is structured around:
51
60
- Policy layers (who can mint, burn, pause, etc.)
52
61
53
62
Design goals:
63
+
54
64
- Predictable storage layout
55
65
- Minimal branching in hot paths
56
66
- Explicit revert reasons
@@ -89,19 +99,25 @@ Design goals:
89
99
## Engineering Principles
90
100
91
101
### 1. Correctness Over Convenience
102
+
92
103
Every state mutation is explicit. No hidden side effects. No magical flows.
93
104
94
105
### 2. Invariants First
106
+
95
107
The implementation is written around invariants:
108
+
96
109
- Sum of balances == totalSupply
97
110
- Transfers do not create or destroy value
98
111
- Mint and burn are the only supply-changing operations
99
112
100
113
### 3. Minimal Surface Area
114
+
101
115
No unnecessary features in the core layer. Policy features (roles, caps, pauses, etc.) are intended to be layered on top.
102
116
103
117
### 4. Audit-First Design
118
+
104
119
The code is structured to be:
120
+
105
121
- Readable
106
122
- Traceable
107
123
- Verifiable
@@ -119,6 +135,7 @@ This repository uses Foundry for:
-**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
226
263
227
-
### Help
264
+
### Useful Commands
228
265
229
266
```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>
233
277
```
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.
0 commit comments