This repository contains support for two vendors to be used as fallbacks for each-other:
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
yarn install
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)
yarn install
https://www.docker.com/products/docker-desktop/
If already used, you can adapt the dedicated ports from the docker-compose.yml
.
Check the .env.example
located at the root of the repository for required secrets. To run subqueries locally you'll only need a HELIUS_RPC_KEY
and/or ONFINALITY_RPC_KEY
set (alternatively you can edit apps/*-subquery/project.ts
and add your own RPC)
After dealing with all the necessary dependencies from Getting Started you can start submitting updates to the subquery indexers. The ./apps/*-subquery/package.json
file has some handy scripts for quick configurations.
yarn setup:devnet
The setup
command will:
- generate files with constants from our templates and general constants
- generate
./*-subquery/types
for the project
Using docker you can run an instance of your subquery indexer on your computer. Make sure to have docker desktop booted up.
yarn dev
# or, if you want to skip the templating step or keep some manual changes added after the fact
yarn subquery-play
Note
To test certain events in particular you don't need to wait for the indexer to read everything from the start block. Check project.ts
and replace the startBlock with one from the useful resources section to quickly reach relevant events. You can use the constants to investigate onchain for other key blocks.
- Blocks for quick tests on devnet, lockup
- Stream create:
406699648
(create) - Stream transfer:
406699648
(create),406699649
(transfer)
- Stream create:
- Blocks for quick tests on devnet, airdrops
- Campaign create:
405402287
- Campaign create: