Carbon 是 Solana 上的索引框架。
Carbon is built around a pipeline: datasources stream Solana updates into the runtime, decoders turn raw account and transaction data into typed Rust structures, and processors handle the decoded output in order to build data pipelines and indexers for your applications. Each part is modular, so you can swap RPC streams for Geyser streams, generated decoders for custom ones, or logging processors for Postgres, GraphQL, analytics, bots, and other application-specific sinks.
Start with a decoder. Use one of Carbon's existing program decoders, or generate one from your program IDL:
npx @sevenlabs-hq/carbon-cli parse \
--idl ./idl.json \
--out-dir ./my-program-decoder \
--name my-program
Then add a datasource and wire them together in a pipeline:
…
Then implement a processor for the typed instruction data you care about:
use carbon_core::{
error::CarbonResult,
instruction::InstructionProcessorInputType,
processor::Processor,
};
use carbon_my_program_decoder::instructions::MyProgramInstruction;
struct MyProcessor;
impl Processor>
for MyProcessor
{
async fn process(
&mut self,
input: &InstructionProcessorInputType,
) -> CarbonResult {
log::info!("instruction: {:?}", input.decoded_instruction);
Ok(())
}
}
The same pattern works with any decoder and any datasource: import the decoder for the Solana program you care about, import the datasource that matches your latency or backfill requirements, then implement a processor for the typed data you want to handle.
Carbon includes maintained datasources and decoders so most indexers can start from existing building blocks instead of custom ingestion or decoding code.
Datasource crates cover the common ways Solana data is consumed:
See datasources/ for the full list.
Decoder crates cover widely used Solana programs across core SPL programs, DeFi, NFTs, infrastructure, and more. They expose typed accounts, instructions, events, and optional serde, Postgres, and GraphQL integrations.
Use an existing decoder when one is available, or generate one from an Anchor or
Codama IDL with carbon-cli parse.
See decoders/ for the full list.
The examples/ directory contains runnable indexers for the common
ways Carbon is used: Geyser streaming, public RPC streaming, transaction
backfills, account-state loading, validator snapshots, custom datasources, and
Postgres-backed GraphQL APIs.
Each example is a workspace crate and can be run from the repository root:
cargo run --release -p block-subscribe-rpc-carbon-example
Contributions are welcome. See CONTRIBUTING.md for the
development setup, local checks, and contribution guidelines.
Carbon is licensed under the MIT license.
暂无开放 Issues,或尚未同步最近议题。