Skip to content

SimonSuckut/Solidity_Uint512

Repository files navigation

uint512 • tests lints GitHub GitHub package.json version

This project demonstrates uint512 representation and arithmetic for the solidity language (which is limited to 2**256). It comes with an example implementation, as well as tests.

Arithmetic Support

  • Addition (512 + 512 → 512)

  • Subtraction (512 - 512 → 512),

  • Multiplication (256 × 256 → 512), (512 × 256 → 512)

  • Division (512 / 256 → 256)

  • Square root (256 → 256) and (512 → 256).

NOTE: All functions are gas optimized as far I know. Feel free to contribute if you know more advanced algorithms, spot possibilities for gas improvements or just want to extend the library.

First time with Forge/Foundry?

See the official Foundry installation instructions.

Then, install the foundry toolchain installer (foundryup) with:

curl -L https://foundry.paradigm.xyz | bash

Now that you've installed the foundryup binary, anytime you need to get the latest forge or cast binaries, you can run foundryup.

So, simply execute:

foundryup

🎉 Foundry is installed! 🎉

Writing Tests with Foundry

With Foundry, tests are written in Solidity! 🥳

Create a test file for your contract in the src/tests/ directory.

For example, src/Greeter.sol has its test file defined in ./src/tests/Greeter.t.sol.

To learn more about writing tests in Solidity for Foundry and Dapptools, reference Rari Capital's solmate repository largely created by @transmissions11.

Configure Foundry

Using foundry.toml, Foundry is easily configurable.

For a full list of configuration options, see the Foundry configuration documentation.

Install DappTools

Install DappTools using their installation guide.

Getting started with Hardhat👷‍♂️

npx install hardhat --save-dev
npx hardhat accounts
npx hardhat compile
npx hardhat clean
npx hardhat test
npx hardhat node
node scripts/sample-script.js
npx hardhat help

License

AGPL-3.0-only

Acknowledgements

Disclaimer

These smart contracts are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions, loss of transmitted information or loss of funds. The creators are not liable for any of the foregoing. Users should proceed with caution and use at their own risk.

About

Solidity Uint512 Math

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published