Crate ethers_solc[][src]

Expand description

ethers-solc

Utilities for working with native solc and compiling projects.

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();
}

Re-exports

pub use artifacts::CompilerInput;
pub use artifacts::CompilerOutput;
pub use artifacts::EvmVersion;

Modules

Solc artifact types

Support for compiling contracts

Utility functions

Structs

Helper struct for serializing --allow-paths arguments to Solc

An Artifacts implementation that uses a compact representation

Handles contract compiling

The outcome of Project::compile

Where to find all files or where to write them

Abstraction over solc command line utility

The config to use when compiling the contracts

Constants

Berlin support https://blog.soliditylang.org/2021/06/10/solidity-0.8.5-release-announcement/

Support for configuring the EVM version https://blog.soliditylang.org/2018/03/08/solidity-0.4.21-release-announcement/

Istanbul support https://blog.soliditylang.org/2019/12/09/solidity-0.5.14-release-announcement/

London support https://blog.soliditylang.org/2021/08/11/solidity-0.8.7-release-announcement/

Petersburg support https://blog.soliditylang.org/2019/03/05/solidity-0.5.5-release-announcement/

The name of the solc binary on the system

Traits