[]Struct ethers_contract::Abigen

pub struct Abigen { /* fields omitted */ }
This is supported on 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>, 

This is supported on 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>, 

This is supported on 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

This is supported on 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>, 

This is supported on 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>

This is supported on 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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,