pub struct Abigen { /* private fields */ }
Expand description

Builder struct for generating type-safe bindings Rust code directly in your project from a contract’s ABI. This is equivalent to code generated by macro use_contract.

Example

Running the code below will generate a file called erc721.rs containing the bindings inside, which exports an erc struct, along with all its events. Put into a build.rs file this will generate the bindings during cargo build.

    use anyhow::{Ok, Result};
    use substreams_ethereum::Abigen;

    fn main() -> Result<(), anyhow::Error> {
        Abigen::new("ERC721", "abi/erc721.json")?
            .generate()?
            .write_to_file("src/abi/erc721.rs")?;

        Ok(())
    }

Implementations

Builder struct for generating type-safe bindings Rust code directly in your project from a contract’s ABI. This is equivalent to code generated by macro use_contract.

Example

Running the code below will generate a file called erc721.rs containing the bindings inside, which exports an erc struct, along with all its events. Put into a build.rs file this will generate the bindings during cargo build.

    use anyhow::{Ok, Result};
    use substreams_ethereum::Abigen;

    fn main() -> Result<(), anyhow::Error> {
        Abigen::new("ERC721", "abi/erc721.json")?
            .generate()?
            .write_to_file("src/abi/erc721.rs")?;

        Ok(())
    }

Creates a new builder for the given contract name and where the ABI JSON file can be found at path, which is relative to the your crate’s root directory (where Cargo.toml file is located).

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

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.