pub struct Solc {
    pub solc: PathBuf,
    pub base_path: Option<PathBuf>,
    pub args: Vec<String>,
}
Expand description

Abstraction over solc command line utility

Supports sync and async functions.

By default the solc path is configured as follows, with descending priority:

  1. SOLC_PATH environment variable
  2. svm’s global_version (set via svm use <version>), stored at <svm_home>/.global_version
  3. solc otherwise

Fields

solc: PathBuf

Path to the solc executable

base_path: Option<PathBuf>args: Vec<String>

Additional arguments passed to the solc exectuable

Implementations

A new instance which points to solc

Adds an argument to pass to the solc command.

Adds multiple arguments to pass to the solc.

Returns the directory in which svm stores all versions

This will be ~/.svm on unix

Returns the semver::Version svm’s .global_version is currently set to. global_version is configured with (svm use <version>)

This will read the version string (eg: “0.8.9”) that the ~/.svm/.global_version file contains

Returns the list of all solc instances installed at SVM_HOME

Returns the path for a svm installed version.

Example
 use ethers_solc::Solc;
let solc = Solc::find_svm_installed_version("0.8.9").unwrap();
assert_eq!(solc, Some(Solc::new("~/.svm/0.8.9/solc-0.8.9")));

Assuming the versions array is sorted, it returns the first element which satisfies the provided VersionReq

Parses the given source looking for the pragma definition and returns the corresponding SemVer version requirement.

Returns the corresponding SemVer version requirement for the solidity version

Convenience function for compiling all sources under the given path

Same as Self::compile(), but only returns those files which are included in the CompilerInput.

In other words, this removes those files from the CompilerOutput that are not included in the provided CompilerInput.

Example
 use ethers_solc::{CompilerInput, Solc};
let solc = Solc::default();
let input = CompilerInput::new("./contracts")?[0].clone();
let output = solc.compile_exact(&input)?;

Run solc --stand-json and return the solc’s output as CompilerOutput

Example
 use ethers_solc::{CompilerInput, Solc};
let solc = Solc::default();
let input = CompilerInput::new("./contracts")?;
let output = solc.compile(&input)?;

Run solc --stand-json and return the solc’s output as the given json output

Returns the version from the configured solc

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Serialize this value into the given Serde serializer. Read more

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

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

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.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more