ProtobufRust code, let's initiate our Rust project and generate some code to set us up to write our handlers:
Cargo.tomlfile to look like this:
wasm. Think of
wasmcode as a binary instruction format that can be run in a virtual machine. When your Rust code is compiled, it will generate a
package, we first need to specify:
dependencies. We specify explicitly the
[target.wasm32-unknown-unknown.dependencies]) target since our handlers compile down to a WASM module:
ethabi: This crate will be used to decode events from your ABI, required for
hex-literal: This crate will be used to define bytes from hexadecimal string literal at compile time.
substreams: This crate offers all the basic building blocks for your handlers.
substreams-ethereum: This crate offers all the Ethereum constructs (blocks, transactions, eth) as well as useful
wasm,we need to configure Rust to target the correct architecture. Add this file at the root of your Substreams directory
substreams-ethereumcrate offers an
AbigenAPI to generate Rust types from a contract's ABI.
build.rsfile in the root of our Substreams project:
src/abi.Next, we will create a
mod.rsfile in that folder to export the generated Rust code