Set up Rust toolchain and install Substreams CLI for Substreams development.
TL;DR: Substreams CLI is a powerful tool for building, deploying, and managing Substreams, a blockchain data indexing technology. It requires setting up a Rust environment and installing dependencies before the CLI itself. Once installed, developers can access a wide range of commands to streamline Substreams development, enabling efficient extraction and transformation of blockchain data.
In the previous article in this series, we learned that extracting blockchain data in a fast and reliable way is complex and challenging. We also saw how Substreams, a powerful blockchain data indexing technology, provides a seamless solution to this issue.
In this second article, we’re diving deeper into Substreams development, focusing on the introduction of the Substreams Command Line Interface (CLI). We will cover installation instructions and provide a brief overview of essential commands, enabling developers to extract and transform blockchain data.
What is Substreams CLI?
Substreams CLI is the primary user interface and tool for building, deploying, and managing Substreams. It exposes many commands to developers, enabling a wide range of features.
Building Substreams involves installing dependencies and Substreams CLI. The dependency installation step involves installing a Rust compilation environment and a Rust package.
A critical Rust component is the Substreams SDK, which includes all the Rust modules to build Substreams.
Let’s see these steps in more detail.
1. Setup essentials: installing dependencies
As discussed earlier, before we dive into the installation of the Substreams CLI itself, we need to set up a few dependencies. These dependencies are essential for the smooth installation of the Substreams CLI.
1.1 Set up a Rust compilation environment
On a basic level, Substreams consists of several Rust modules talking to each other, and building those modules requires a working Rust compilation environment. There are many ways to install Rust, and the installation method differs according to your machine or OS.
For MacOS or Linux, install Rust through curl by using the following command:
curl --proto '=https' --tlsv1.2 -sSf <https://sh.rustup.rs> | sh
source $HOME/.cargo/env # to configure your current shell
For other operating systems, refer to the Rust installation page.
To check if Rust is installed or not, open a terminal or command prompt and type the following command:
rustc --version
If Rust is installed, this command will display the installed version of Rust. If it’s not installed, you’ll see a message indicating that the command rustc was not found.
1.2 Configure Rust toolchain
Once your machine is running a Rust compilation environment, the next item we need is the wasm32-unknown-unknown target installed on your Rust installation. You can install it using the below command:
rustup target add wasm32-unknown-unknown
2. Install the Substreams CLI
For MacOS, use the following command:
brew install streamingfast/tap/substreams
For the next step, which is pre-compiled binary installation, refer to StreamingFast’s instructions.
3. Validate your installation
After completing the above steps, verify whether the Substreams CLI is installed by executing the following command:
$ substreams --version
substreams version 1.10.2 (Commit bfef85c, Built 2024-09-06T18:57:30Z)
4. Get started with Substreams CLI
The substreams CLI exposes many commands to developers, enabling a range of features.
To access or view all the available commands offered by Substreams CLI, run the substreams command in a terminal with the -h flag.
$ substreams —-help
Any place where <package> is specified, a 'substreams.yaml', a local '.spkg' file or an https://...spkg file can be specified
Usage:
substreams [command]
Available Commands:
alpha Group of commands that are currently being available for testing but could change at any time
auth Login command for Substreams development
build Build the project according to substreams.yaml
codegen Code generator for substreams
completion Generate the autocompletion script for the specified shell
graph Generate mermaid-js graph document
gui Stream module outputs from a given package on a remote endpoint
help Help about any command
info Display package modules and docs
init Initialize a new, working Substreams project from scratch
inspect Display low-level package structure
pack Build an .spkg out of a .yaml manifest
protogen Generate Rust bindings from a package
run Stream module outputs from a given package on a remote endpoint
tools Developer tools related to substreams
To learn about the use case of a specific command available in CLI, run the following command in a terminal.
substreams [command] --help
Wrapping up
The Substreams CLI is a powerful tool for building, deploying, and managing Substreams. Its installation process is straightforward and supports a variety of operating systems. Once installed, you’ll have access to a wide range of features and commands that help you build Substreams smoothly.
Now, unleash your creativity and start crafting your first Substreams with the Substreams CLI, diving into its full potential!
Learn & explore more
- Substreams 101: If you are new to Substreams, we highly recommend reading Substreams 101: A Novice’s Introduction.
- Substreams Official Docs: Visit the official Substreams documentation to learn more about Substreams and CLI installation process.
- Pinax’s YouTube Channel: Visit our YouTube channel to access advanced content and tutorials on Substreams.
💡 This article answers questions like:
- What is Substreams CLI?
- What are the basic commands available in Substreams CLI?
- How does a developer install Substreams CLI?
- How does a developer install Rust?
No Comments