Substreams CLI reference
StreamingFast Substreams command line interface (CLI)
substreams
CLI reference overview
substreams
CLI reference overviewThe substreams
command line interface (CLI) is the primary user interface and the main tool for sending requests and receiving data.
The substreams
CLI exposes many commands to developers enabling a range of features.
Note: When a package is specified, it is optional. If you do use it, you can use:
Local
substreams.yaml
configuration filesLocal
.spkg
package filesRemote
.spkg
package URLsLocal directory containing a
substreams.yaml
file
If you choose to not use it, make sure that you are in a directory that contains a substreams.yaml file. Otherwise, you will get a usage error back.
init
init
The init
command allows you to initialize a Substreams project for several blockchains. It is a conversational-like command: you will be asked several questions and a project with the specicied features will be created for you.
The options included in the init
command will evolve over time, but every blockchain should, at least, contain one option.
build
build
The build
command:
Generates the necessary Protobufs specified in the
substreams.yaml
file.Compiles the Rust code.
Creates a Substreams package file (
.spkg
).
run
run
The run
command connects to a Substreams endpoint and begins processing data.
The details of the run command are:
-e mainnet.eth.streamingfast.io:443
is the endpoint of the provider running your Substreams.-t +1
or--stop-block
only requests a single block; the stop block is the manifest'sinitialBlock
+ 1.substreams.yaml
is the path where you have defined your Substreams manifest. You can use a.spkg
orsubstreams.yaml
configuration file.module_name
is the module we want torun
, referring to the module name defined in the Substreams manifest.
Tip: Passing a different -s
or --start-block
runs prior modules at a higher speed. Output is provided at the requested start block, keeping snapshots along the way if you want to process it again.
Headers
The -H
option in of the run
or gui
command allows you to dynamically pass headers with the gRPC request. This is useful when overriding default parameters in the Substreams execution.
X-Sf-Substreams-Parallel-Jobs Header
The X-Sf-Substreams-Parallel-Jobs
header sets the number of parallel jobs to use in the Substreams execution. By default, 10 jobs are used.
Run example with output
The output of the gravatar_updates
module starting at block 6200807
will print a message resembling:
Note: The -o
or --output
flag alters the output format.
The available output display options are:
ui
, a nicely formatted, UI-driven interface, displaying progress information and execution logs.json
, an indented stream of data, not displaying progress information or logs, only data output for blocks proceeding the start block.jsonl
, same asjson
showing every individual output on a single line.
gui
gui
The gui
command pops up a terminal-based graphical user interface.
Its parameters are very similar to those of run
, but provides a UI to navigate the results instead of a stream of data.
Replay mode
When you run a gui
session, a file called replay.log
gets written with the contents of the streamed data that persists after closing the GUI.
You can reload the data without hitting the server again using --replay
. The data is immediately reloaded in the GUI, ready for more inspection.
pack
(DEPRECATED)
pack
(DEPRECATED)(DEPRECATED: use build
instead)
The pack
command builds a shippable, importable package from a substreams.yaml
manifest file.
The output of the pack
command will print a message resembling:
info
info
The info
command prints out the contents of a package for inspection. It works on both local and remote yaml
or spkg
configuration files.
The output of the info
command will print a message resembling:
graph
graph
The graph
command prints out a visual graph of the package in the mermaid-js format.
Tip: Mermaid Live Editor is the visual editor used by Substreams.
The graph
command will result in a graphic resembling:
inspect
inspect
The inspect
command reaches deep into the file structure of a yaml
configuration file or spkg
package and is used mostly for debugging, or if you're curious_._
The output of the inspect
command will print a message resembling:
codegen
codegen
The codegen
command generates a code for a specific sink taking as a Substreams module as input. There are two code generators available: subgraph
and sql
.
Subgraph
Generates a Substreams-powered Subgraph project from the Substreams package found in the current folder.
SQL
Generates a SQL-based Substreams project from the Substreams package found in the current folder.
Help
To view a list of available commands and brief explanations in the substreams
CLI, run the substreams
command in a terminal passing the -h
flag. You can use this help reference at any time.
Last updated