1. API reference

Feature flags

Every Cargo feature in carbon-core, the datasource and metrics crates, and generated decoders, with what each one enables.

On this page

This page lists every Cargo feature in the Carbon 2.0.0 crates and what turning it on adds. Use it when a module or type from another reference page is missing from your build, or when you want to trim dependencies.

Summary#

CrateFeaturesDefault
carbon-coremacros, postgres, graphql, yellowstonemacros
carbon-prometheus-metricshttp-serverhttp-server
Generated decoders (carbon-*-decoder)serde, postgres, graphql, base58 (CLI-generated only)none
carbon-macros, carbon-proc-macros, carbon-test-utilsnone
carbon-log-metricsnone
Every datasource cratenone

carbon-core#

Defined in crates/core/Cargo.toml.

macros#

Re-exports the declarative and procedural macros at the carbon_core crate root. On by default.

TOML
carbon-core = "2.0.0" # includes "macros"

Details. Adds the carbon-macros and carbon-proc-macros dependencies and re-exports everything they export, so you can write carbon_core::try_decode_instructions!, carbon_core::instruction_decoder_collection! and #[derive(carbon_core::InstructionType)]. It also re-exports log (hidden from the docs) for use inside the generated macro code. Every decoder crate enables this feature on carbon-core itself, so turning it off in your own Cargo.toml has no effect once you depend on a decoder.

Example.

TOML
carbon-core = { version = "2.0.0", default-features = false } # no macro re-exports

See also. Macros.

postgres#

Adds the carbon_core::postgres module: Postgres row types, processors and SQL primitives built on sqlx.

TOML
carbon-core = { version = "2.0.0", features = ["postgres"] }

Details. Enables the optional dependencies sqlx (with postgres, rust_decimal and bigdecimal), sqlx_migrator, num-traits and bigdecimal. It also changes PipelineBuilder::build: with this feature, build registers the six postgres_* metrics, so they appear in every metrics export even if you use no Postgres processor. You add sqlx yourself as well, with a runtime feature such as runtime-tokio-rustls, to open a connection pool.

Example.

Cargo.toml
[dependencies]
carbon-core = { version = "2.0.0", features = ["postgres"] }
sqlx = { version = "0.8.6", features = ["runtime-tokio-rustls", "postgres"] }
sqlx_migrator = "0.17.0"

See also. Postgres reference, Postgres guide, Metrics.

graphql#

Adds the carbon_core::graphql module: Juniper scalars for Solana types and an Axum router helper.

TOML
carbon-core = { version = "2.0.0", features = ["graphql"] }

Details. Enables the optional dependencies juniper, axum and juniper_axum, and compiles carbon_core::graphql::primitives and carbon_core::graphql::server. It does not enable postgres. The GraphQL code that generated decoders emit queries Postgres, so in practice you enable both.

Example.

Cargo.toml
[dependencies]
carbon-core = { version = "2.0.0", features = ["postgres", "graphql"] }
axum = "0.8.7"

See also. GraphQL reference, GraphQL guide.

yellowstone#

Adds carbon_core::transformers::yellowstone, which converts Yellowstone gRPC protobuf messages into Solana transaction types.

TOML
carbon-core = { version = "2.0.0", features = ["yellowstone"] }

Details. Enables the optional dependencies yellowstone-grpc-proto, solana-account-decoder-client-types, solana-transaction-error and wincode. The module provides create_tx_versioned, create_tx_meta, ConversionError and ConversionResult. carbon-yellowstone-grpc-datasource and carbon-helius-laserstream-datasource turn this feature on for you; enable it yourself only to convert protobuf messages in your own datasource.

Example.

Cargo.toml
[dependencies]
carbon-core = { version = "2.0.0", features = ["yellowstone"] }
yellowstone-grpc-proto = { version = "=12.7.0", default-features = false }

See also. Custom datasource, Yellowstone gRPC.

Implicit dependency features#

carbon-core names its optional dependencies without the dep: prefix in macros, postgres and graphql. Cargo therefore also exposes carbon-macros, carbon-proc-macros, sqlx, sqlx_migrator, num-traits, bigdecimal, juniper, axum and juniper_axum as feature names. Enabling one of these adds the dependency but does not compile any Carbon module, because the code checks for macros, postgres and graphql. Use the named features above instead.

carbon-prometheus-metrics#

Defined in metrics/prometheus-metrics/Cargo.toml.

http-server#

Adds the built-in /metrics HTTP server. On by default.

TOML
carbon-prometheus-metrics = "2.0.0" # includes "http-server"

Details. Enables the optional dependencies axum, tokio, tower and tower-http. It provides PrometheusServerConfig, PrometheusMetrics::with_server, PrometheusMetrics::start_server, run_metrics_server, run_default_metrics_server and run_metrics_server_with_config. Without it, only PrometheusMetrics::new, prometheus_text and format_snapshot remain, and you serve the text from your own HTTP stack.

Example.

TOML
carbon-prometheus-metrics = { version = "2.0.0", default-features = false } # text rendering only

See also. Metrics reference, Prometheus guide.

Datasource crates#

No datasource crate defines features. Two of them turn on a carbon-core feature for you:

CrateVersionEnables on carbon-core
carbon-yellowstone-grpc-datasource2.0.0yellowstone
carbon-helius-laserstream-datasource2.0.0yellowstone
carbon-helius-atlas-ws-datasource2.0.0none
carbon-helius-gpa-v2-datasource2.0.0none
carbon-helius-gtfa-datasource2.0.0none
carbon-rpc-block-crawler-datasource2.0.0none
carbon-rpc-block-subscribe-datasource2.0.0none
carbon-rpc-gpa-datasource2.0.0none
carbon-rpc-program-subscribe-datasource2.0.0none
carbon-rpc-transaction-crawler-datasource2.0.0none
carbon-stream-message-datasource2.0.0none
carbon-validator-snapshot-datasource2.0.0none

Every datasource depends on carbon-core with default features, so macros is always on in a pipeline that uses one.

carbon-jetstreamer-datasource and carbon-jito-shredstream-grpc-datasource are excluded from the 2.0.0 workspace. They remain at 1.0.0 on the Carbon 1.x and Solana 3 stack and do not work with carbon-core 2.0.0: mixing them in causes duplicate solana-pubkey type errors (see Errors).

Generated decoders#

Every decoder crate in the repository (63 of them at 2.0.0) and every decoder generated by carbon-cli parse has the same feature set. All are off by default. Examples below use carbon-meteora-dlmm-decoder; the same applies to carbon-token-program-decoder and the rest.

serde#

Derives serde::Serialize and serde::Deserialize on every account, instruction, event and type in the decoder.

TOML
carbon-meteora-dlmm-decoder = { version = "2.0.0", features = ["serde"] }

Details. Enables the optional serde dependency, plus serde-big-array in decoders that have fixed arrays longer than 32 elements (meteora-dlmm does, token-program does not), because serde only supports arrays up to 32 elements. The account and instruction enums are serialized with an adjacent tag, for example {"type": "Swap", "data": {…}}. A Pubkey serializes as a JSON array of 32 numbers, not a base58 string, unless the decoder also has base58.

Example.

Rust
// With features = ["serde"]
let json = serde_json::to_string(&decoded_instruction)?;

See also. Decoders.

postgres (decoder)#

Adds accounts::postgres and instructions::postgres: one row type per account and instruction, plus sqlx_migrator migrations that create their tables.

TOML
carbon-meteora-dlmm-decoder = { version = "2.0.0", features = ["postgres"] }

Details. Enables carbon-core/postgres, sqlx, async-trait, sqlx_migrator and the decoder's serde feature. You get types such as accounts::postgres::LbPairRow and the migrations MeteoraDlmmAccountsMigration and MeteoraDlmmInstructionsMigration, named after the program.

Example.

Cargo.toml
[dependencies]
carbon-core = { version = "2.0.0", features = ["postgres"] }
carbon-meteora-dlmm-decoder = { version = "2.0.0", features = ["postgres"] }

See also. Postgres guide, Postgres reference.

graphql (decoder)#

Adds the decoder's GraphQL schema types and a graphql module with QueryRoot and GraphQLContext, which read rows from Postgres.

TOML
carbon-meteora-dlmm-decoder = { version = "2.0.0", features = ["postgres", "graphql"] }

Details. Enables carbon-core/graphql, juniper and the decoder's serde feature. It does not enable the decoder's postgres feature, but the generated GraphQL code uses the Postgres row types and sqlx. Enabling graphql alone fails to compile with errors such as cannot find `postgres` in `instructions` and cannot find module or crate `sqlx` . Always enable postgres with it.

Example.

Cargo.toml
[dependencies]
carbon-core = { version = "2.0.0", features = ["postgres", "graphql"] }
carbon-meteora-dlmm-decoder = { version = "2.0.0", features = ["postgres", "graphql"] }

See also. GraphQL guide, GraphQL reference.

base58#

Serializes Pubkey fields as base58 strings in serde output. Only in decoders you generate with --with-base58 true.

TOML
my-program-decoder = { path = "../decoder", features = ["base58"] }

Details. Defined as base58 = ["serde"] by the CLI renderer. It adds a private base58 module with serialize and serialize_option helpers and #[serde(serialize_with = …)] attributes on Pubkey and Option<Pubkey> fields of instructions, instruction accounts and events. Deserialization is unchanged. None of the decoder crates published to crates.io define this feature.

Example.

Terminal
npx -y @sevenlabs-hq/carbon-cli@2.0.0 parse --idl ./idl.json --out-dir ./decoder --with-base58 true
Terminal
pnpm dlx @sevenlabs-hq/carbon-cli@2.0.0 parse --idl ./idl.json --out-dir ./decoder --with-base58 true
Terminal
bunx @sevenlabs-hq/carbon-cli@2.0.0 parse --idl ./idl.json --out-dir ./decoder --with-base58 true
Terminal
yarn dlx @sevenlabs-hq/carbon-cli@2.0.0 parse --idl ./idl.json --out-dir ./decoder --with-base58 true

See also. CLI reference, Generate a decoder.

Scaffolded indexer features#

carbon-cli scaffold writes an indexer crate whose [features] table contains default = [], plus postgres = [] and graphql = [] when you choose those options. These features are empty markers: the scaffold enables the real postgres/graphql features directly on its carbon-core and decoder dependencies. See the CLI reference.

Your endpoints

Code samples use these instead of the placeholders, so you can copy and run them as they are. They’re stored only in this browser and never sent anywhere.