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.
init
initThe 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 specified 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.
substreams initbuild
buildThe build command:
Generates the necessary Protobufs specified in the
substreams.yamlfile.Compiles the Rust code.
Creates a Substreams package file (
.spkg).
Performance optimization
The build command uses hash-based caching to avoid regenerating proto files when they haven't changed. This significantly improves build performance by:
Computing a hash of proto files, exclude paths, and generation settings
Storing the hash in a
.last_generated_hashfile in the output directorySkipping proto generation when the hash matches and generated files exist
Displaying status messages indicating whether proto generation was skipped or run
This optimization is particularly beneficial for:
Iterative development workflows
CI/CD pipelines with unchanged proto definitions
Large projects with extensive proto files
Reading manifest from stdin
The build command supports reading the manifest from stdin by using --manifest "-". This allows for dynamic manifest generation and processing pipelines.
Example with envsubst:
This approach is useful for:
Dynamic configuration using environment variables
Pre-processing manifest files with template tools
CI/CD pipelines with dynamic manifest generation
run
runThe run command connects to a Substreams endpoint and begins processing data. It supports reading manifest from stdin using "-".
The details of the run command are:
-e mainnet.eth.streamingfast.io:443is the endpoint of the provider running your Substreams.-t +1or--stop-blockonly requests a single block; the stop block is the manifest'sinitialBlock+ 1.substreams.yamlis the path where you have defined your Substreams manifest. You can use a.spkgorsubstreams.yamlconfiguration file.module_nameis 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 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-Substreams-Parallel-Workers Header
The X-Substreams-Parallel-Workers header sets the number of parallel jobs to use in the Substreams execution. By default, 10 jobs are used. Most authentication backends will prevent setting this header to a higher value than the what the auth provides.
Run example with output
The output of the gravatar_updates module starting at block 6200807 will print a message resembling:
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 asjsonshowing every individual output on a single line.
gui
guiThe gui command pops up a terminal-based graphical user interface. It supports reading manifest from stdin using "-".
Its parameters are very similar to those of run, but the gui command 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.
GUI Cheatsheet
Cheatsheet
These are the shortcuts that you can use to navigate the GUI. You can always get more information by pressing the ? key.
Switch screen (Request, Progress, Output)
tab
Restart
r
Quit
q
Navigate Blocks - Forward
p
Navigate Blocks - Backwards
o
Navigate Blocks - Go To
= + block number + enter
Navigate Modules - Forward
i
Navigate Modules - Backwards
u
Search
/ + text + enter
Commands information
?
pack (DEPRECATED)
pack (DEPRECATED)(DEPRECATED: use build instead)
The pack command builds a shippable, importable package from a substreams.yaml manifest file. It supports reading manifest from stdin using "-".
The output of the pack command will print a message resembling:
info
infoThe info command prints out the contents of a package for inspection. It works on both local and remote yaml or spkg configuration files, and supports reading manifest from stdin using "-".
The output of the info command will print a message resembling:
graph
graphThe graph command prints out a visual graph of the package in the mermaid-js format. It supports reading manifest from stdin using "-".
Tip: Mermaid Live Editor is the visual editor used by Substreams.
The graph command will result in a graphic resembling:
inspect
inspectThe 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. It supports reading manifest from stdin using "-".
The output of the inspect command will print a message resembling:
protogen
protogenThe protogen command generates Rust bindings from a package. It supports reading manifest from stdin using "-".
codegen
codegenThe codegen command generates a code for a specific sink taking a Substreams module as input.
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
Was this helpful?

