pub enum Source {
    Local(PathBuf),
    Http(Url),
    Etherscan(Address),
    Npm(String),
}
Expand description

A source of an artifact JSON.

Variants

Local(PathBuf)

File on the local file system.

Http(Url)

Resource in the internet, available via HTTP(S).

Etherscan(Address)

An address of a mainnet contract, available via Etherscan.

Artifacts loaded from etherstan can be parsed using the truffle loader.

Note that Etherscan rate-limits requests to their API, to avoid this, provide an Etherscan API key via the ETHERSCAN_API_KEY environment variable.

Npm(String)

The package identifier of an NPM package with a path to an artifact or ABI to be retrieved from unpkg.

Implementations

Parses an artifact source from a string.

This method accepts the following:

  • relative path to a contract JSON file on the local filesystem, for example build/IERC20.json. This relative path is rooted in the current working directory. To specify the root for relative paths, use [with_root] function;

  • absolute path to a contract JSON file on the local filesystem, or a file URL, for example /build/IERC20.json, or the same path using URL: file:///build/IERC20.json;

  • an HTTP(S) URL pointing to artifact JSON or contract ABI JSON;

  • a URL with etherscan scheme and a mainnet contract address. For example etherscan:0xC02AA.... Alternatively, specify an etherscan URL: https://etherscan.io/address/0xC02AA.... The contract artifact or ABI will be retrieved through [Etherscan];

  • a URL with npm scheme, NPM package name, an optional version and a path (defaulting to the latest version and index.js). For example npm:@openzeppelin/contracts/build/contracts/IERC20.json. The contract artifact or ABI will be retrieved through [unpkg].

Parses an artifact source from a string and uses the specified root directory for resolving relative paths. See [parse] for more details on supported source strings.

Creates a local filesystem source from a path string.

Creates an HTTP source from a URL.

Creates an Etherscan source from contract address on mainnet.

Creates an NPM source from a package path.

Retrieves the source JSON of the artifact.

This will either read the JSON from the file system or retrieve a contract ABI from the network, depending on the source type.

Contract ABIs will be wrapped into a JSON object, so that you can load them using the truffle loader.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. 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.

Calls U::from(self).

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

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
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.