Use these steps to conveniently open your repository in a Gitpod.
- First, copy this repository
- Grab a StreamingFast key from https://app.streamingfast.io/
- Create a Gitpod account
- Configure a
STREAMINGFAST_KEY
variable in your Gitpod account settings - Open your repository as a Gitpod workspace
Use this quickstart guide to set up your environment to use Substreams locally.
First, copy this repository and clone it.
Follow Installation Requirements instructions on official Substreams documentation wesite.
Ensure that substreams
CLI works as expected:
substreams -v
version (...)
substreams protogen ./substreams.yaml --exclude-paths="sf/substreams,google"
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.wasm
We're now ready to run our example Substream!
Don't forget to be at the root of the project to run the following commands
# to run the map module
substreams run -e mainnet.eth.streamingfast.io:443 substreams.yaml map_transfers --start-block 12292922 --stop-block +1
# to run the store module (and the map module in the background)
substreams run -e mainnet.eth.streamingfast.io:443 substreams.yaml store_transfers --start-block 12292922 --stop-block +1
Let's break down everything happening above.
substreams
is our executable-e mainnet.eth.streamingfast.io:443
is the provider going to run our Substreamssubstream.yaml
is the path where we have defined our Substreams Manifestmap_transfers
(orstore_transfers
) this is the module which we want to run, defined in the manifest--start-block 12292922
start from block12292922
--stop-block +1
only request a single block (stop block will be manifest's start block + 1)
Here is the example of an output of the map_transfers
starting at 12292922
block for only 1
block.
The [...]
was added to abbreviate the JSON output as there was a lot of ERC20 transfers.
----------- IRREVERSIBLE BLOCK #12,292,922 (12292922) ---------------
map_transfers: message "eth.erc721.v1.Transfers": {
"transfers": [
{
"from": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"to": "q6cWGn+2nIjhbtn0Vc5it5HuTQM=",
"trxHash": "z7GX9i7Fx/DnGhHsDEoOOUo6pB21OG6FUm+GyEs/J5Y=",
"ordinal": "85"
},
<continued>,
{
"from": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"to": "q6cWGn+2nIjhbtn0Vc5it5HuTQM=",
"tokenId": "29",
"trxHash": "z7GX9i7Fx/DnGhHsDEoOOUo6pB21OG6FUm+GyEs/J5Y=",
"ordinal": "114"
}
]
}
Bytes are rendered with base64 encoding by default, so it might be a little troubling to see
q6cWGn+2nIjhbtn0Vc5it5HuTQM=
as an Ethereum address, but it's actuallyaba7161a7fb69c88e16ed9f455ce62b791ee4d03
, you can usestring
instead ofbytes
if you prefer that in your Protobuf definitions.
Congratulations! You've successfully run a Substreams.
- Read the documentation at https://substreams.streamingfast.io.
- Look at Playground for more learning examples.