Struct ethers_core::utils::Solc[][src]

pub struct Solc {
    pub solc_path: Option<PathBuf>,
    pub paths: Vec<String>,
    pub optimizer: Option<usize>,
    pub evm_version: EvmVersion,
    pub allowed_paths: Vec<PathBuf>,
    pub args: Vec<String>,
}
Expand description

Solidity Compiler Bindings

Assumes that solc is installed and available in the caller’s $PATH. Any calls will panic otherwise.

By default, it uses 200 optimizer runs and Istanbul as the EVM version

Examples

use ethers_core::utils::Solc;

// Give it a glob
let contracts = Solc::new("./contracts/*")
    .optimizer(Some(200))
    .build()?;

// this will return None if the specified contract did not exist in the compiled
// files
let contract = contracts.get("SimpleStorage").expect("contract not found");

Fields

solc_path: Option<PathBuf>

The path to the Solc binary

paths: Vec<String>

The path where contracts will be read from

optimizer: Option<usize>

Number of optimizer runs. None for no optimization

evm_version: EvmVersion

Evm Version

allowed_paths: Vec<PathBuf>

Paths for importing other libraries

args: Vec<String>

Additional arguments to pass to solc

Implementations

Instantiates The Solc builder with the provided glob of Solidity files

Instantiates the Solc builder for the provided paths

Gets the ABI for the contracts

Builds the contracts and returns a hashmap for each named contract

Returns the output of solc --version

Panics

If solc is not found

Sets the EVM version for compilation

Sets the path to the solc binary

Sets the optimizer runs (default = 200). None indicates no optimization

use ethers_core::utils::Solc;

// No optimization
let contracts = Solc::new("./contracts/*")
    .optimizer(None)
    .build().unwrap();

// Some(200) is default, optimizer on with 200 runs
// .arg() allows passing arbitrary args to solc command
let optimized_contracts = Solc::new("./contracts/*")
    .optimizer(Some(200))
    .arg("--metadata-hash=none")
    .build().unwrap();

Sets the allowed paths for using files from outside the same directory

Adds an argument to pass to solc

Adds multiple arguments to pass to solc

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.