Use this quickstart guide to set up your environment to use Substreams locally.
First, copy this repository and clone it.
We're going to be using the Rust programming language, to develop some custom logic.
There are several ways to install Rust, but for the sake of brevity:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env # to configure your current shell
brew install streamingfast/tap/substreams
- Download the binary
# Use correct binary for your platform
wget https://github.com/streamingfast/substreams/releases/download/v0.0.20/substreams_0.0.20_linux_x86_64.tar.gz
tar -xzvf substreams_0.0.20_linux_x86_64.tar.gz
export PATH="`pwd`:$PATH"
Check https://github.com/streamingfast/substreams/releases and use the latest release available
Ensure that substreams
CLI works as expected:
substreams -v
version (...)
At this point, we're ready to build our WASM binary and Protobuf definitions.
cargo build --target wasm32-unknown-unknown --release
The resulting WASM artifact will be found at ./target/wasm32-unknown-unknown/release/substreams_aptos_stats.wasm
We're now ready to run our example Substreams!
Don't forget to be at the root of the project to run the following commands
substreams run -e testnet.aptos.streamingfast.io:443 substreams.yaml store_count --stop-block +100
Generating protobuf is required only when changes to protobuf definitions has been made and updated corresponding Rust code must be generated. To update the corresponding Rust code, follow this instructions.
https://buf.build is a tool used to simplify the generation of typed structures in any language. It invokes protoc
and simplifies a good number of things. Substreams packages are compatible with buf Images.
See the installation instructions here.
substreams protogen ./substreams.yaml --exclude-paths="sf/substreams,google"
Congratulations! You've successfully run a Substreams.
- Read the documentation at https://github.com/streamingfast/substreams under Documentation.
- Look at Playground for more learning examples.