[−][src]Macro ethcontract_derive::contract
contract!() { /* proc-macro */ }
Proc macro to generate type-safe bindings to a contract. This macro accepts
a path to a Truffle artifact JSON file. Note that this path is rooted in
the crate's root CARGO_MANIFEST_DIR
.
ⓘThis example is not tested
ethcontract::contract!("build/contracts/MyContract.json");
Currently the proc macro accepts additional parameters to configure some aspects of the code generation. Specifically it accepts:
crate
: The name of theethcontract
crate. This is useful if the crate was renamed in theCargo.toml
for whatever reason.deployments
: A list of additional addresses of deployed contract for specified network IDs. This mapping allowsMyContract::deployed
to work for networks that are not included in the Truffle artifact'snetworks
property. Note that deployments defined this way take precedence over the ones defined in the Truffle artifact. This parameter is intended to be used to manually specify contract addresses for test environments, be it testnet addresses that may defer from the originally published artifact or deterministic contract addresses on local development nodes.
ⓘThis example is not tested
ethcontract::contract!( "build/contracts/MyContract.json", crate = ethcontract_rename, deployments { 4 => "0x000102030405060708090a0b0c0d0e0f10111213" 5777 => "0x0123456789012345678901234567890123456789" }, );
See ethcontract
module level documentation for additional
information.