From Yellowstone to Substreams
Introduction
Both Substreams and Yellowstone allow you consume Solana data in a fast and reliable way through gRPC connection. However, there are some unique capabilities of Substreams that make it shine:
Improvements over Yellowstone
Substreams is a programmable stack, while Yellowstone is only a gRPC interface with the Geyser plugin.
Substreams gives you access to the full Solana
Block
, and you can use Rust to filter and output the schema that you need.Substreams runs on top of a parallelization engine, which speeds up the indexing times.
Substreams allows you to filter data and create your own output schema (you choose what data model gets ouputted from the Substreams).
Substreams is a composable stack, which means that you can reuse other Substreams modules built by other people (take a look at the Substreams Registry).
Substreams has native integrations with many sinks (people where you want to consume the data), such as Postgres or Subgraphs. You can also use libraries like Go, Rust or JavaScript.
Pricing
Yellowstone is usually charged based on credit units. A single response from Yellowstone will cost X credit units.
In Substreams, you are charged depending on the amount of data (TBs) that you consume from the endpoint. Therefore, you will be charge exactly for what the Solana blockchain is producing.
To reduce the cost even more, we have caches of data that will help you consume less data (blocks without voting transactions cache or transactions filtered by program ID cache, for example).
Examples
In Substreams, you can build your own Substreams modules to filter and output the data that you need.
By default, you can consume the most basic information in Solana (full Blocks, transactions and account changes). In the following examples, you will see different example in differents formats: using the Substreams CLI, consuming the data in JavaScript, or consuming the data in Go.
Installation
Install the Substreams CLI in your computer.
Verify that the installation is correct by running:
Get the Full Solana Block
The https://spkg.io/streamingfast/solana_common-v0.3.3.spkg Substreams package contains several modules to get the most basic Solana data, such as blocks or transactions. The blocks_without_votes
module retrieves Solana blocks, removing all the voting transactions.
Run the following command in your terminal:
substreams gui
allows you to run a Substreams module and debug its content (move across the content, search, etc).https://spkg.io/streamingfast/solana_common-v0.3.3.spkg
is the Substreams package that extracts the most basic information on Solana.blocks_without_votes
is the module that extracts full Blocks (removing voting transactions).--start-block=320100000
specifies where you want to start consuming data.
You will enter the Substreams GUI view, which will allow you to start the stream and move across blocks.
IMPORTANT:
To start the streaming of data, press the
Enter
key.To move across tabs (
Request
,Output
...), press theTab
key.To move across blocks, press the
o
andp
keys.To exist the GUI screen, press the
q
key.
Get Transactions Filtered by Program ID (Pump.Fun)
The solana-common
package also allows you to filter transaction by program ID and/or accounts by using the transactions_by_programid_without_votes
module.
Run the following command in your terminal:
https://spkg.io/streamingfast/solana_common-v0.3.3.spkg
package contains several modules that extract the most basic Solana data.transactions_by_programid_without_votes
is the module that extracts filtered transactions.-p "transactions_by_programid_without_votes=program:6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"
specifies the parameters passed to the Substreams module. Thetransactions_by_programid_without_votes
expects one or several filters to be provided. In this example, you filter transactions that contain data from the6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P
program (Pump Fun program).
Get Account Changes History
You can also get the history of an account (with some limitations) using the solana-accounts-foundational module.
Run the following command in your terminal:
https://spkg.io/streamingfast/solana_accounts_foundational-v0.1.1.spkg
package contains module to filter Solana account changes data.filtered_accounts
is the module that extracts filtered accounts.-p "filtered_accounts=account:5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1"
specifies the parameters passed to the Substreams module. Thefiltered_accounts
module expects one or several filters to be provided. In this example, you filter to only get data from the5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1
account.
Last updated
Was this helpful?