[][src]Struct ethers_contract::Abigen

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

pub fn new<S>(contract_name: &str, abi_source: S) -> Result<Abigen, Error> where
    S: AsRef<str>, 
[src]

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>, 
[src]

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[src]

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>, 
[src]

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>[src]

Generates the contract bindings.

Auto Trait Implementations

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> Conv for T

impl<T> FmtForward for T

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

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

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

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> TryConv for T

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