on Solana

In this guide, you'll learn how to initialize a Solana-based Substreams project within the Dev Container.

Step 1: Initialize Your Solana Substreams Project

  1. Open the Dev Container and follow the on-screen steps to initialize your project.

  2. Running substreams init will give you the option to choose between two Solana project options. Select the one that best fits your requirements:

    • sol-minimal: Creates a simple Substreams that extracts raw Solana block data and generates corresponding Rust code. This path will start you with the full raw block, you can navigate to the substreams.yaml (the manifest) to modify the input.

    • sol-transactions: Creates a Substreams that filters Solana transactions based on one or more Program IDs and/or Account IDs, using the cached Solana Foundational Module.

    • sol-anchor-beta: Given an Anchor IDL, create a Substreams that decodes instructions and events. If an IDL isn’t available using the idl subcommand within the Anchor CLI, you’ll need to provide it yourself.

The modules within Solana Common exclude voting transactions, to benefit from a 75% reduction in data processing size and costs, delay your stream by over 1000 blocks from head. This can be done using the sleep function in Rust.

To access voting transactions, use the full Solana block, sf.solana.type.v1.Block, as input.

Step 2: Visualize the Data

  1. Run substreams auth to create your account and generate an authentication token (JWT), then pass this token back as input.

  2. Now you can freely use the substreams gui to visualize and iterate on your extracted data.

Step 2.5: (Optionally) Transform the Data

Within the generated directories, modify your Substreams modules to include additional filters, aggregations, and transformations, then update the manifest accordingly. To learn more about this, visit the How-to-Guides

Step 3: Load the Data

To make your Substreams queryable (as opposed to direct streaming), you can automatically generate a Subgraph (known as a Substreams-powered subgraph) or SQL-DB sink.

Subgraph

  1. Run substreams codegen subgraph to initialize the sink, producing the necessary files and function definitions.

  2. Create your subgraph mappings within the mappings.ts and associated entities within the schema.graphql.

  3. Deploy

SQL

  1. Run substreams codegen sql and choose from either ClickHouse or Postgres to initialize the sink, producing the necessary files.

  2. Run substreams build build the Substreams:SQL sink.

  3. Run substreams-sink-sql to sink the data into your selected SQL DB.

Note: Run help to better navigate the development environment and check the health of containers.

Additional Resources

You may find these additional resources helpful for developing your first Solana application.

Dev Container Reference

The Dev Container Reference helps you navigate the container and its common errors.

CLI Reference

The CLI reference lets you explore all the tools available in the Substreams CLI.

Substreams Components Reference

The Components Reference dives deeper into navigating the substreams.yaml.

Last updated