Substreams for Solana Developers
Substreams allows you to easily extract data from the the Solana blockchain. With Substreams, you can retrieve transactions, instructions or accounts, taking advantage of its powerful streaming technology. It's super fast!
Getting Started
First, you must consider whether you want to develop your own Substreams or consume a ready-to-use Substreams. It is possible that someone has already built a Substreams package to extract the data you want; you can explore Substreams packages in the Substreams Registry.
If you have found a Substreams package that fits your needs, then explore the Consume Substreams section. At the most basic level you should cover:
Choose how you want to consume the data:
If you can't find a Substreams package that fits your needs, then you can go ahead and develop your own Substreams. The Develop Substreams section of the documentation covers everything you need to know about building a Substreams from scratch. At the most basic level, you should cover:
Tutorials
If you want to deep dive into the code, you can follow one or several of the Solana Tutorials available in the documentation.
The Explore Solana Tutorial will teach you the most basic operations you can perform in a Solana Substreams.
The Solana Token Tracker Tutorial will teach how to track an SPL token of your choice.
The NFT Trades Tutorial will help you in extracting data from different NFT exchanges.
The DEX Trades Tutorial will help you in extracting data from different decentralized exchanges.
The Solana Data Model
A Substreams module is, essentially, a Rust function that extracts data from the blockchain. In order to specify which data you want to retrieve, Substreams gives you access to the abstraction of a full Solana block.
In the following example, a Solana block (solana::Block
) is passed as a parameter. Then, a custom object defined by the user, BlockMeta
, is emitted as output, containing some relevant fields (slot
, hash
, parent_hash
):
The Block object holds other important data, such as:
The Account Address Tables
In Solana, the account concept plays a very important role. However, the original Solana data model imposes a restriction on the number of accounts that a single transaction can have. The Account Address Tables is a way to overcome this restriction, allowing developers to increase the number of accounts per transaction.
The resolved_accounts() method of the ConfirmedTransaction object includes a ready-to-use array of accounts, including accounts from the Lookup Table.
Last updated