Giter VIP home page Giter VIP logo

foundry's Introduction

foundry

Github Actions Telegram Chat Crates.io

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.

Foundry consists of:

  • Forge: Ethereum testing framework (like Truffle, Hardhat and Dapptools).
  • Cast: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.

demo

Dependencies

Currently both Forge and Cast rely on the libudev-dev package. This package may be preinstalled for your system, but is also available in most packages managers.

Forge

cargo install --git https://github.com/gakonst/foundry --bin forge --locked

If you are on a x86/x86_64 Unix machine, you can also use --features=solc-asm to enable Sha2 Assembly instructions, which further speedup the compilation pipeline cache.

We also recommend using forgeup for managing various versions of Forge, so that you can easily test out bleeding edge changes in open pull requests or forks from contributors.

More documentation can be found in the forge package and in the CLI README.

Features

  1. Fast & flexible compilation pipeline:
    1. Automatic Solidity compiler version detection & installation (under ~/.svm)
    2. Incremental compilation & caching: Only changed files are re-compiled
    3. Parallel compilation
    4. Non-standard directory structures support (e.g. can build Hardhat repos)
  2. Tests are written in Solidity (like in DappTools)
  3. Fast fuzz Tests with shrinking of inputs & printing of counter-examples
  4. Fast remote RPC forking mode leveraging Rust's async infrastructure like tokio
  5. Flexible debug logging:
    1. Dapptools-style, using DsTest's emitted logs
    2. Hardhat-style, using the popular console.sol contract
  6. Portable (5-10MB) & easy to install statically linked binary without requiring Nix or any other package manager
  7. Abstracted over EVM implementations (currently supported: Sputnik, EvmOdin)

How Fast?

Forge is quite fast at both compiling (leveraging the ethers-solc package) and testing.

Some benchmarks below:

Project Forge DappTools Speedup
guni-lev 28.6s 2m36s 5.45x
solmate 6s 46s 7.66x
geb 11s 40s 3.63x
vaults 1.4s 5.5s 3.9x

It also works with "non-standard" directory structures (i.e. contracts not in src/, libraries not in lib/). When tested with openzeppelin-contracts, Hardhat compilation took 15.244s, whereas Forge took 9.449 (~4s cached)

Cast

Cast is a swiss army knife for interacting with Ethereum applications from the command line.

cargo install --git https://github.com/gakonst/foundry --bin cast
// Get USDC's total supply
cast call 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 "totalSupply()(uint256)" --rpc-url <..your node url>

More documentation can be found in the cast package.

Contributing

Directory structure

This repository contains several Rust crates:

  • forge: Library for building and testing a Solidity repository.
  • cast: Library for interacting with a live Ethereum JSON-RPC compatible node, or for parsing data.
  • cli: Command line interfaces to cast and forge.
  • evm-adapters: Unified layer of abstraction over multiple EVM types. Currently supported EVMs: Sputnik, Evmodin.
  • utils: Utilities for parsing ABI data, will eventually be upstreamed to ethers-rs.

Rust Toolchain

We use the stable Rust toolchain. Install by running: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh.

Minimum Supported Rust Version

The current minimum supported Rust version is rustc 1.54.0 (a178d0322 2021-07-26).

Testing

cargo check
cargo test
cargo doc --open

Formatting

We use the nightly toolchain for formatting and linting.

cargo +nightly fmt
cargo +nightly clippy --all-features -- -D warnings

Getting Help

First, see if the answer to your question can be found in the API documentation. If the answer is not there, try opening an issue with the question.

Join the foundry telegram to chat with the community!

Acknowledgements

  • Foundry is a clean-room rewrite of the testing framework dapptools. None of this would have been possible without the DappHub team's work over the years.
  • Matthias Seitz: Created ethers-solc which is the backbone of our compilation pipeline, as well as countless contributions to ethers, in particular the abigen macros.
  • Rohit Narurkar: Created the Rust Solidity version manager svm-rs which we use to auto-detect and manage multiple Solidity versions.
  • All the other contributors to the ethers-rs & foundry repositories and chatrooms.

foundry's People

Contributors

0x-r4bbit avatar anish-agnihotri avatar brockelmore avatar drawnwren avatar endophysics avatar gakonst avatar guanqun avatar hammeiam avatar joshiedo avatar jparklev avatar laizy avatar mattsse avatar maxsam4 avatar ncitron avatar odyslam avatar rajivpo avatar reem avatar rjected avatar roynalnaruto avatar samwilsn avatar shekhirin avatar tarrencev avatar transmissions11 avatar tynes avatar univerz avatar williamberman avatar wolflo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.