Struct ethers_core::utils::Solc [−][src]
pub struct Solc {
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
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
Gets the ABI for the contracts
Builds the contracts and returns a hashmap for each named contract
Sets the EVM version for compilation
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 multiple arguments to pass to solc