GitXplorerGitXplorer
f

foundry-rust-template

public
235 stars
34 forks
3 issues

Commits

List of commits on branch master.
Verified
b09674367afc8ff73fc5f4e51feeb373c04efc8c

Merge pull request #11 from jjoshm/master

mmattsse committed 4 months ago
Verified
bcb18c9d95aeb24e7567e9997698837058c672c6

Merge pull request #14 from yash-atreya/yash/mig_alloy

mmattsse committed 7 months ago
Unverified
951eb60ab90ea7ae09a2a4232bd96e4975300593

latest bindings ec4f214

yyash-atreya committed 7 months ago
Unverified
ea956bd6826a95e4f005166591e83459cc6ef071

fix ci

yyash-atreya committed 7 months ago
Unverified
9a4c84353b7e918b2b1d200d2030b4b64c109f3d

use alloy bindings

yyash-atreya committed 7 months ago
Unverified
1f446216824cfd4fb3f67c221f6eda0323246bf7

fix makefile setup target

ccruzz1 committed 9 months ago

README

The README file for this repository.

Foundry Rust Monorepo Template

Rust Solidity Telegram Chat

Template for quickly getting started with developing Rust applications that leverage Foundry for EVM smart contract development.

Continuous Integration is already set up to test both your Rust and Solidity code, as well as ensure formatting and that your Rust bindings match the Solidity build artifacts.

Directory Structure

The project is structured as a mixed Rust workspace with a Foundry project under contracts/ and typesafe auto-generated bindings to the contracts under crates/bindings/.

├── Cargo.toml
├── app // <-- Your Rust application logic
├── contracts // <- The smart contracts + tests using Foundry
├── crates
    └── bindings // <-- Generated bindings to the smart contracts' abis (like Typechain)

Testing

Given the repository contains both Solidity and Rust code, there's 2 different workflows.

Solidity

Forge is using submodules to manage dependencies. Initialize the dependencies:

If you are in the root directory of the project, run:

forge install --root ./contracts

If you are in in contracts/:

forge install

Then, run the tests:

If you are in the root directory of the project, run:

forge test --root ./contracts

If you are in in contracts/:

forge test

Rust

cargo test

Generating Rust bindings to the contracts

Rust bindings to the contracts can be generated via forge bind, which requires first building your contracts:

forge build --root ./contracts
forge bind --bindings-path ./crates/bindings --root ./contracts --crate-name bindings

Any follow-on calls to forge bind will check that the generated bindings match the ones under the build files. If you want to re-generate your bindings, pass the --overwrite flag to your forge bind command.

Installing Foundry

First run the command below to get foundryup, the Foundry toolchain installer:

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

Then, in a new terminal session or after reloading your PATH, run it to get the latest forge and cast binaries:

foundryup

For more, see the official docs.