brew install rust
rustup target add wasm32-unknown-unknown
Other crates will be installed later with substreams run
or substreams gui
.
https://www.docker.com/products/docker-desktop/
brew install streamingfast/tap/substreams
brew install bufbuild/buf/buf
This will also install a dependency for Protobuf support.
You'll need to create an account or log into an existing one on The Graph Market. This will grant you access to a token which enables indexing.
- Docs: https://docs.substreams.dev/reference-material/substreams-cli/authentication
- Dashboard: https://thegraph.market/
The CLI utility looks for SUBSTREAMS_API_TOKEN
being declared in your shell.
export SUBSTREAMS_API_TOKEN=<ACCESS_TOKEN>
Either manually add the token to your shell or follow the automated process with:
cd ./subgraph
yarn substream-auth # or simply substreams auth
Don't forget to run the .substreams.env
file if you generate it, for export to apply its effects and make the key available in the terminal.
The system uses buf.build to create/validate protobufs. It rate-limits after 10 queries / hour, so it's advised to create a free account for active development.
buf registry login
Create or look for the subgraph profile and look for the authenticate & deploy section on the right hand side. You need to run the command below and paste the auth string.
cd ./subgraph
yarn subgraph-auth # or simply substreams auth
After dealing with all the necessary dependencies from Getting Started and Registration you can start submitting updates for the substreams / subgraphs. The ./subgraph/package.json
file has some handy scripts for quick configurations so we're going to assume commands will from now on be run from inside the ./subgraph
folder.
yarn setup:devnet
The setup
command will:
- generate
./substream.yaml
, with the cluster configurations - generate
./src/generated
, with the typed models based on./proto
- build the substream
*.spkg
based on./substreams.yaml
,./proto
and./buf.gen.yaml
- generate
./subgraph/generated
based on*.spkg
and./subgraphs/bug.gen.yaml
To develop new features into the substream, look into modifying the following files:
./proto/program.proto
- Add data structures to save transaction values into./src/lib.rs
- Implement support for new events or data structures
To test your changes locally, you can run:
# Relies on files already generated using yarn setup:devnet
yarn substream-gui:devnet
1. Create a new subgraph on thegraph.com/studio
Create a placeholder project in the Studio. We'll need the auth
key and the name.
- Make sure the
dataSources.source.package.file
is set to the actual name of the substreamspkg
(produced after build) - Make sure the name for protogen also matches
- Replace slug in
subgraph-deploy
(package.json) with the one created at step 1
yarn setup:devnet
To engage with the devnet
substream gui you can run:
cd ./subgraph
yarn stream-gui:devnet
To configure a subgraph for deployment on the studio, you can run:
cd ./subgraph
yarn setup:devnet
- The manifest reference for the structure of
substreams.yaml
- Examples of existing modules show some versions of query strings (they can have
||
operators)