Hsiang-xxs / huff-math

OpenZeppelin's SafeMath library implemented as a contract in the Huff language. Spoiler: It's cheap.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Huff Math

OpenZeppelin's SafeMath library implemented as a contract in the Huff language.

Spoiler: It's cheap.

Table Of Contents

Getting Started

Requirements

Please install the following:

  • Git
    • You'll know you've done it right if you can run git --version
  • Foundry / Foundryup
    • This will install forge, cast, and anvil
    • 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
  • 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

Quickstart

git clone https://github.com/alexroan/huff-math.git
cd huff-math
make

Gas Comparison

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.

Testing

make test or forge test

Misc

Disclaimer

None of the contacts have been audited, use at your own risk.

Contributing

Contributions are always welcome! Open a PR or an issue!

Thank You!

Resources

Helpful Debugging Resources:

About

OpenZeppelin's SafeMath library implemented as a contract in the Huff language. Spoiler: It's cheap.


Languages

Language:Solidity 72.1%Language:TypeScript 27.4%Language:JavaScript 0.2%Language:Shell 0.2%Language:Makefile 0.1%Language:Nix 0.0%