Common Solidity contract patterns, based on Openzeppelin's contract library, implemented in the Huff language:
- Access Control:
access/Ownable.huff
- Safe Math:
math/SafeMath.huff
Spoiler: It's cheap.
Please install the following:
- Git
- You'll know you've done it right if you can run
git --version
- You'll know you've done it right if you can run
- Foundry / Foundryup
- This will install
forge
,cast
, andanvil
- You can test you've installed them right by running
forge --version
and get an output like:forge 0.2.0 (f016135 2022-07-04T00:15:02.930499Z)
- To get the latest of each, just run
foundryup
- This will install
- Huff Compiler
- You'll know you've done it right if you can run
huffc --version
and get an output like:huffc 0.2.0
- You'll know you've done it right if you can run
git clone https://github.com/alexroan/huff-math.git
cd huff-math
make
Gas comparison tests between the Huff implementation and native Solidity checked math can be found in the test files. The naming convention for these comparisons are:
function test<function_name>Gas[Huff/Solidity]() public {...}
Results can be found in .gas-snapshot in the repo root.
make test
or forge test
None of the contacts have been audited, use at your own risk.
Contributions are always welcome! Open a PR or an issue!
Thank You!