25 releases (16 stable)

2.0.13 Jan 30, 2024
2.0.11 Nov 16, 2023
2.0.8 Jul 15, 2023
2.0.2 Mar 28, 2023
0.1.1 Nov 29, 2021

#1323 in Magic Beans

Download history 25383/week @ 2023-10-29 25926/week @ 2023-11-05 27434/week @ 2023-11-12 31429/week @ 2023-11-19 35317/week @ 2023-11-26 35104/week @ 2023-12-03 33378/week @ 2023-12-10 31477/week @ 2023-12-17 17241/week @ 2023-12-24 23247/week @ 2023-12-31 38452/week @ 2024-01-07 42760/week @ 2024-01-14 40605/week @ 2024-01-21 53610/week @ 2024-01-28 44702/week @ 2024-02-04 37726/week @ 2024-02-11

179,500 downloads per month
Used in 35 crates (7 directly)

MIT/Apache

1.5MB
34K SLoC

ethers-solc

Utilities for working with native solc and compiling projects.

Warning

This crate is deprecated in favor of foundry-compilers (foundry-rs/compilers). See #2667 for more information.

To also compile contracts during cargo build (so that ethers abigen! can pull in updated abi automatically) you can configure a ethers_solc::Project in your build.rs file

First add ethers-solc to your cargo build-dependencies.

Once you compiled the project, you can configure cargo change detection with rerun_if_sources_changed, so that cargo will execute the build.rs file if a contract in the sources directory has changed

[build-dependencies]
ethers-solc = { git = "https://github.com/gakonst/ethers-rs" }
use ethers_solc::{Project, ProjectPathsConfig};

fn main() {
    // configure the project with all its paths, solc, cache etc.
    let project = Project::builder()
        .paths(ProjectPathsConfig::hardhat(env!("CARGO_MANIFEST_DIR")).unwrap())
        .build()
        .unwrap();
    let output = project.compile().unwrap();

    // Tell Cargo that if a source file changes, to rerun this build script.
    project.rerun_if_sources_changed();
}

Dependencies

~13–31MB
~486K SLoC