Coder Social home page Coder Social logo

foundry-rs / foundry Goto Github PK

View Code? Open in Web Editor NEW
7.7K 74.0 1.5K 34.98 MB

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

Home Page: https://getfoundry.sh

License: Apache License 2.0

Rust 99.59% Solidity 0.10% Shell 0.25% Dockerfile 0.04% Nix 0.03%
rust solidity evm testing fuzzing mainnet-fork blockchain ethereum tooling framework

foundry's Introduction

Foundry logo

Foundry

Github Actions Telegram Chat Telegram Support

Install | User Book | Developer Docs | Crate Docs

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.
  • Anvil: Local Ethereum node, akin to Ganache, Hardhat Network.
  • Chisel: Fast, utilitarian, and verbose solidity REPL.

Need help getting started with Foundry? Read the ๐Ÿ“– Foundry Book (WIP)!

Demo

Installation

See the installation guide in the book.

If you're experiencing any issues while installing, check out Getting Help and the FAQ.

Forge

Features

  • Fast & flexible compilation pipeline
    • Automatic Solidity compiler version detection & installation (under ~/.svm)
    • Incremental compilation & caching: Only changed files are re-compiled
    • Parallel compilation
    • Non-standard directory structures support (e.g. Hardhat repos)
  • Tests are written in Solidity (like in DappTools)
  • Fast fuzz testing with shrinking of inputs & printing of counter-examples
  • Fast remote RPC forking mode, leveraging Rust's async infrastructure like tokio
  • Flexible debug logging
    • DappTools-style, using DsTest's emitted logs
    • Hardhat-style, using the popular console.sol contract
  • Portable (5-10MB) & easy to install without requiring Nix or any other package manager
  • Fast CI with the Foundry GitHub action.

How Fast?

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

See the benchmarks below. More benchmarks can be found in the v0.2.0 announcement post and in the Convex Shutdown Simulation repository.

Testing Benchmarks

Project Forge DappTools Speedup
transmissions11/solmate 2.8s 6m34s 140x
reflexer-labs/geb 0.4s 23s 57.5x
Rari-Capital/vaults 0.28s 6.5s 23x

Note: In the above benchmarks, compilation was always skipped

Compilation Benchmarks

Compilation benchmarks

Takeaway: Forge compilation is consistently faster by a factor of 1.7-11.3x, depending on the amount of caching involved.

Cast

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

More documentation can be found in the cast package.

Configuration

Using foundry.toml

Foundry is designed to be very configurable. You can configure Foundry using a file called foundry.toml in the root of your project, or any other parent directory. See config package for all available options.

Configuration can be arbitrarily namespaced by profiles. The default profile is named default (see "Default Profile").

You can select another profile using the FOUNDRY_PROFILE environment variable. You can also override parts of your configuration using FOUNDRY_ or DAPP_ prefixed environment variables, like FOUNDRY_SRC.

forge init creates a basic, extendable foundry.toml file.

To see your current configuration, run forge config. To see only basic options (as set with forge init), run forge config --basic. This can be used to create a new foundry.toml file with forge config --basic > foundry.toml.

By default forge config shows the currently selected foundry profile and its values. It also accepts the same arguments as forge build.

DappTools Compatibility

You can re-use your .dapprc environment variables by running source .dapprc before using a Foundry tool.

Additional Configuration

You can find additional setup and configurations guides in the Foundry Book:

Contributing

See our contributing guidelines.

Getting Help

First, see if the answer to your question can be found in book, or in the relevant crate.

If the answer is not there:

If you want to contribute, or follow along with contributor discussion, you can use our main telegram to chat with us about the development of Foundry!

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.
  • Brock Elmore: For extending the VM's cheatcodes and implementing structured call tracing, a critical feature for debugging smart contract calls.
  • All the other contributors to the ethers-rs & foundry repositories and chatrooms.

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.