Expand description
A library for writing Substreams handlers.
Substreams consists of a number of modules which provide structs and macros for implementing Substreams handlers. The handlers are defined in your Manifest. Learn more about Substreams at https://substreams.streamingfast.io
§Handler Examples
Below are a few map handler examples. The signature of the handler function is based
on the inputs and output defined in the map module definition in the Manifest. There
are a few things to note:
- Best practice is to name your 
mapmodule functionmap_<your_action> mapmodule function must always return a Result<Proto, E>- The Result must have an Error type set to crate::errors::Error
 
 use substreams::prelude::{StoreGet, StoreNew};
 use substreams::{errors::Error, store};
 use substreams::store::{DeltaBigDecimal, StoreGetProto};
 /// Map handler which takes a source as input
 #[substreams::handlers::map]
 fn map_transfers(blk: eth::Block) -> Result<pb::Custom, Error> {
     unimplemented!("do something");
 }
 /// Map handler which takes a source, and a store in get mode as inputs
 #[substreams::handlers::map]
 fn map_ownerships(blk: eth::Block, my_things: StoreGetProto<pb::Pairs>) -> Result<pb::Custom, Error> {
     unimplemented!("do something");
 }
 /// Map handler which takes a source, another map, and a store in get mode as inputs
 #[substreams::handlers::map]
 fn map_mints(blk: eth::Block, mints: pb::Custom, myt_things: StoreGetProto<pb::Pairs>) -> Result<pb::Custom, Error> {
     unimplemented!("do something");
 }
 /// Map handler which takes a source, another map, and a store in delta mode as inputs
 #[substreams::handlers::map]
 fn map_db(blk: eth::Block, mints: pb::Custom, store_deltas: store::Deltas<DeltaBigDecimal>) -> Result<pb::Custom, Error> {
     unimplemented!("do something");
 }
 /// Map handler that can return no output or an error
 #[substreams::handlers::map]
 fn map_optional_transfers(blk: eth::Block) -> Result<Option<pb::Custom>, Error> {
     Ok(None)
 }
 /// Map handler that can return no output
 #[substreams::handlers::map]
 fn map_maybe_transfers(blk: eth::Block) -> Option<pb::Custom> {
     None
 }
 /// Map handler that can return its output only and directly
 #[substreams::handlers::map]
 fn map_direct_transfers(blk: eth::Block) -> pb::Custom {
     unimplemented!("do something");
 }Below are a few store handler examples. The signature of the handler function is based
on the inputs defined in the store module definition in the Manifest. There
are a few things to note:
- Best practice is to name your 
mapmodule functionstore_<your_action> storemodule function must return nothing
use substreams::store;
use substreams::prelude::{StoreGet, StoreNew};
use substreams::store::{DeltaBigDecimal, StoreGetProto, StoreAddInt64};
#[substreams::handlers::store]
fn store_transfers(objects: pb::Custom, output: StoreAddInt64) {
    // to something
}
#[substreams::handlers::store]
fn store_ownerships(objects: pb::Custom, store: StoreGetProto<pb::Pairs>, output: StoreAddInt64) {
    // to something
}
#[substreams::handlers::store]
fn store_mints(objects: pb::Custom, store: StoreGetProto<pb::Pairs>, another_store: StoreGetProto<pb::Tokens>, store_deltas: store::Deltas<DeltaBigDecimal>, output: StoreAddInt64) {
    // to something
}Re-exports§
pub use expr_parser::expr_matcher;pub use expr_parser::matches_keys_in_parsed_expr;pub use expr_parser::ExprMatcher;
Modules§
- errors
 - Error proxy for Substreams.
 - expr_
parser  - handlers
 - Handler macros for Substreams.
 - key
 - The key module contains functions for working extracting segments from key.
 - log
 - Log Implementation for Substreams
 - memory
 - pb
 - Protobuf generated Substreams models
 - prelude
 - A prelude that makes all store traits available.
 - proto
 - Protobuf helpers for Substreams.
 - scalar
 - store
 - Store Implementation for Substreams.
 
Macros§
- hex
 - Macro for converting sequence of string literals containing hex-encoded data into an array of bytes.
 
Structs§
- Hex
 - Hex is a simple wrapper type that you can use to wrap your type so that it prints in lower hexadecimal format when use as a formatting argument.
 
Functions§
- output
 - output_
raw  - register_
panic_ hook  - Registers a Substreams custom panic hook. The panic hook is invoked when then handler panics
 - skip_
empty_ output