LogoLogo
Package RegistryThe Graph
  • Introduction
  • Getting Started
  • Tutorials
    • Develop Your First Substreams
      • on EVM
      • on Solana
        • Transactions & Instructions
        • Account Changes
      • on Cosmos
        • Injective
        • MANTRA
      • on Starknet
      • on Stellar
    • Publishing a Substreams Package
  • How-To Guides
    • Developing Substreams
      • on EVM
        • Exploring Ethereum
          • Mapping Blocks
          • Filter Transactions
          • Retrieve Events of a Smart Contract
      • on Solana
        • Explore Solana
          • Filter Instructions
          • Filter Transactions
        • SPL Token Tracker
        • NFT Trades
        • DEX Trades
      • on Cosmos
        • Injective
          • Simple Substreams Example
          • Foundational Modules
          • Dojo DEX USDT Volume Subgraph Example
    • Using a Substreams Sink
      • Substreams:SQL
      • Substreams:Subgraph
        • Triggers
        • Graph Out
      • Substreams:Stream
        • JavaScript
        • Go
      • Substreams:PubSub
      • Community Sinks
        • MongoDB
        • Files
        • Key-Value Store
        • Prometheus
    • EVM Extensions
      • Making eth_calls
    • Getting Started Using Rust and Protobuf
      • Rust
        • Option struct
        • Result struct
      • Protobuf Schemas
    • From Yellowstone to Substreams
  • Reference Material
    • Chains and endpoints
      • Ethereum Data Model
    • Never Miss Data
    • Development Container Reference
    • Substreams CLI
      • Install the CLI
      • Authentication
      • Substreams CLI reference
    • Substreams Components
      • Packages
      • Modules
        • Module types
        • Inputs
        • Output
        • Module handlers
        • Module handler creation
        • Indexes
        • Keys in stores
        • Dynamic data sources
        • Aggregation Windows
        • Parameterized Modules
      • Manifests Reference
    • Substreams Architecture
    • Graph-Node
      • Local Development
      • Publish to The Graph Network
    • Indexer Reference
      • Test Substreams Locally
    • Logging, Debugging & Testing
    • Change log
    • FAQ
  • Decentralized Indexing
    • What is The Graph?
Powered by GitBook
On this page
  • Introduction
  • Prerequisites
  • Step 1: Set Up a Connection to Solana Account Change Substreams
  • Step 2: Sink the Substreams
  • Step 3: Setting up a Reconnection Policy

Was this helpful?

Edit on GitHub
  1. Tutorials
  2. Develop Your First Substreams
  3. on Solana

Account Changes

PreviousTransactions & InstructionsNexton Cosmos

Last updated 22 days ago

Was this helpful?

Introduction

In this tutorial, you will learn how to consume Solana account change data using Substreams. We will walk you through the process of setting up your environment, configuring your first Substreams stream, and consuming account changes efficiently.

By the end of this tutorial, you will have a working Substreams feed that allows you to track real-time account changes on the Solana blockchain, as well as historical account change data.

Data for Solana account changes is available on a rolling three-month window, the current first streamable slot is 335,410,714.

For each Solana Account block, only the latest update per account is recorded, see the . If an account is deleted, a payload with deleted == True is provided. Additionally, events of low importance we're omitted, such as those with the special owner “Vote11111111…” account or changes that do not affect the account data (ex: lamport changes).

The Account Changes Substreams natively handles a change of ownership upon delete.

Prerequisites

Before you begin, ensure that you have the following:

  1. installed.

  2. A for access to the Solana Account Change data.

  3. Basic knowledge of the command line interface (CLI).

Step 1: Set Up a Connection to Solana Account Change Substreams

Now that you have Substreams CLI installed, we can set up a connection to the Solana Account Change Substreams feed.

Using the , you can choose to stream data directly or use the GUI for a more visual experience. The following gui example filters for Honey Token account data.

 substreams gui  solana-accounts-foundational filtered_accounts -t +10 -p filtered_accounts="owner:TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA || account:4vMsoUT2BWatFweudnQM1xedRLfJgJ7hswhcpz4xgBTy"

This command will benchmark the account change stream within your terminal.

substreams run solana-accounts-foundational filtered_accounts -s -1 -o clock

The Foundational Module has support for filtering on specific accounts and/or owners. You can adjust the query based on your needs.

This tutorial will continue to guide you through filtering, sinking the data, and setting up reconnection policies.

Step 2: Sink the Substreams

Step 3: Setting up a Reconnection Policy

The user's primary responsibility when creating or using a sink is to pass a BlockScopedDataHandler and a BlockUndoSignalHandler implementation(s) which has the following interface:

import (
	pbsubstreamsrpc "github.com/streamingfast/substreams/pb/sf/substreams/rpc/v2"
)

type BlockScopedDataHandler = func(ctx context.Context, cursor *Cursor, data *pbsubstreamsrpc.BlockScopedData) error
type BlockUndoSignalHandler = func(ctx context.Context, cursor *Cursor, undoSignal *pbsubstreamsrpc.BlockUndoSignal) error

Consume the account stream using a callback or make it queryable by using the .

ensures seamless continuity and retraceability by allowing you to resume from the last consumed block if the connection is interrupted, preventing data loss and maintaining a persistent stream.

Protobuf Referece
Substreams CLI
Substreams key
how to use
Solana Accounts Foundational Module
directly in your applicaion
Substreams:SQL sink
Cursor Management