macro_rules! use_contract {
    ($module: ident, $path: expr) => { ... };
}
Expand description

This macro can be used to import an Ethereum ABI file in JSON format and generate all the required bindings for ABI decoding/encoding in Rust, targetting substreams developer experience. You prefer to have the code generated directly, check out Abigen.

    use substreams_ethereum::use_contract;

    use_contract!(erc721, "./examples/abi/erc721.json");

This invocation will generate the following code (signatures only for consiscness):

mod erc721 {
    pub mod events {
        #[derive(Debug, Clone, PartialEq)]
        pub struct Transfer {
            pub from: Vec<u8>,
            pub to: Vec<u8>,
            pub token_id: ethabi::Uint,
        }

        impl Transfer {
            pub fn match_log(log: &substreams_ethereum::pb::eth::v1::Log) -> bool {
               // ...
            }

            pub fn decode(log: &substreams_ethereum::pb::eth::v1::Log) -> Result<Transfer, String> {
               // ...
            }
        }

        // ... Other events ...
    }
}