Substreams
for AntelopeThis library contains the generated protobuffer for the Antelope blocks as well as helper methods to extract and parse block data.
$ cargo add substreams-antelope
Cargo.toml
toml
[dependencies]
substreams = "0.5"
substreams-antelope = "0.2"
src/lib.rs
```rust use substreams::prelude::*; use substreams::errors::Error; use substreams_antelope::{Block, ActionTraces};
fn mapactiontraces(block: Block) -> Result
for trx in block.all_transaction_traces() {
for trace in trx.action_traces {
action_traces.push(trace);
}
}
Ok(ActionTraces { action_traces })
} ```
Or, using actions()
filter to filter all actions of Statelog
type from myaccount
account:
src/lib.rs
```rust
fn mapactions(paramaccount: String, block: substreams_antelope::Block) -> Result
To generate ABI bindings for your smart contract you can add abi/contract.abi.json
file containing the smart contract ABI, as well as the following build.rs
file to the root of your project. This will ensure that src/abi/contract.rs
module containing Rust bindings for your smart contract is always generated in your project:
build.rs
rust
fn main() {
substreams_antelope::Abigen::new("Contract", "abi/gems.blend.abi.json")
.expect("failed to load abi")
.generate()
.expect("failed to generate contract")
.write_to_file("src/abi/gems.blend.abi.rs")
.expect("failed to write contract");
}