Dependencies & Installation
Substreams requires a handful of dependencies to be installed. This section will go through how to get everything installed and setup on your specific operating system.
Rust
A Rust installation is a required dependency for Substreams development.
There are several methods to install Rust.
Installing Rust on your system includes the following tools:
rustup
(Toolchain Manager)rustc
(Compiler)cargo
(Package Manager)
It is recommended to do this by installing the rustup
tool when on MacOS.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
These commands will install Rust on your system, and configure your shell to recognise the Rust toolchain.
Substreams also requires the WebAssembly (WASM) target to have been added to our Rust toolchain. This allows Rust to WASM compilation.
rustup target add wasm32-unknown-unknown
Buf CLI
Substreams utilise Protocol Buffers, or simply referred to as protobufs to define data types for Substreams. Protobufs are a method developed by Google for serializing structured data, allowing for efficient data exchange between different services and languages. We will go over these in further detail in a later section, however, for now we will install the Buf CLI, a required dependency for Substreams.
Installation is available via npm.
npm install @bufbuild/buf
Alternatively, it can be install using Homebrew.
brew install bufbuild/buf/buf
Once installed, you can verify the installation by running the following:
buf --version
Other installation methods can be found here.
Substreams CLI
The Substreams CLI is going to be your go-to tool as a Substreams developer, allowing for functionalities including but not limited to:
- Repository initialisation and codegen (think
graph init
but for Substreams) - Connecting to Substreams endpoints and real-time data streaming
- GUI of real-time data streaming
- Packaging of custom Substreams modules
There are several methods to install the CLI.
It can be installed via Homebrew using the following command:
brew install streamingfast/tap/substreams
If you prefer to install from source, the following commands can be used:
Ensure you have Go installed before running these commandsgit clone https://github.com/streamingfast/substreams
cd substreams
go install -v ./cmd/substreams
Alternatively pre-compiled CLI binaries are available for different OS’.
These CLI releases can be found here.
On MacOS run
LINK=$(curl -s https://api.github.com/repos/streamingfast/substreams/releases/latest | awk "/download.url.*$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m)/ {print \$2}" | sed 's/"//g')
curl -L $LINK | tar zxf -
On Linux run
# Use correct binary for your platform
LINK=$(curl -s https://api.github.com/repos/streamingfast/substreams/releases/latest | awk "/download.url.*linux_$(uname -m)/ {print \$2}" | sed 's/"//g')
curl -L $LINK | tar zxf -
Once installed you can verify the installation by running the following:
substreams --version
Chocolatey & Make - Windows Users
Windows users also are required to install make
. To do this it is recommended to use Chocolatey, a package manager for Windows.
Installing Chocolatey can be done via running the following command into PowerShell:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
More info around Chocolatey installation can be found here.
To then install make using Chocolatey, run the following command:
choco install make