[−]Struct ethers_contract::Abigen
feature="abigen"
only.Builder struct for generating type-safe bindings from a contract's ABI
Note: Your contract's ABI must contain the stateMutability
field. This is
still not supported by Vyper, so you must adjust your ABIs and replace
constant
functions with view
or pure
.
Example
Running the command below will generate a file called token.rs
containing the
bindings inside, which exports an ERC20Token
struct, along with all its events.
Abigen::new("ERC20Token", "./abi.json")?.generate()?.write_to_file("token.rs")?;
Implementations
impl Abigen
pub fn new<S>(contract_name: &str, abi_source: S) -> Result<Abigen, Error> where
S: AsRef<str>,
S: AsRef<str>,
feature="abigen"
only.Creates a new builder with the given ABI JSON source.
pub fn add_method_alias<S1, S2>(self, signature: S1, alias: S2) -> Abigen where
S1: Into<String>,
S2: Into<String>,
S1: Into<String>,
S2: Into<String>,
feature="abigen"
only.Manually adds a solidity method alias to specify what the method name will be in Rust. For solidity methods without an alias, the snake cased method name will be used.
pub fn rustfmt(self, rustfmt: bool) -> Abigen
feature="abigen"
only.Specify whether or not to format the code using a locally installed copy
of rustfmt
.
Note that in case rustfmt
does not exist or produces an error, the
unformatted code will be used.
pub fn add_event_derive<S>(self, derive: S) -> Abigen where
S: Into<String>,
S: Into<String>,
feature="abigen"
only.Add a custom derive to the derives for event structs and enums.
This makes it possible to for example derive serde::Serialize and serde::Deserialize for events.
pub fn generate(self) -> Result<ContractBindings, Error>
feature="abigen"
only.Generates the contract bindings.
Auto Trait Implementations
impl RefUnwindSafe for Abigen
impl Send for Abigen
impl Sync for Abigen
impl Unpin for Abigen
impl UnwindSafe for Abigen
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,