Bubblegum decoder
Decode Bubblegum instructions and accounts in Rust with carbon-bubblegum-decoder 2.0.0. Program ID BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY.
On this page
carbon-bubblegum-decoder decodes the instructions and accounts of the Bubblegum program (BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY): 17 instructions, 2 account types. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.
| Crate | carbon-bubblegum-decoder 2.0.0 |
| Install | cargo add carbon-bubblegum-decoder@2. |
| Program ID | BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY (carbon_) |
| Category | NFTs & metadata |
| Decoder | carbon_ |
| Instruction enum | instructions:: |
| Account enum | accounts:: |
| Features | serde, postgres, graphql (none enabled by default) |
| API docs | docs.rs/carbon-bubblegum-decoder/2.0.0 |
| Source | decoders/bubblegum-decoder |
Other NFT and metadata decoders: Metaplex Core, Metaplex Token Metadata. To decode several in one pipeline, see nFT and metadata decoders.
The serde feature derives Serialize/Deserialize on every type, postgres adds tables and processors for Postgres, and graphql adds a schema for the GraphQL server.
Usage#
This program crawls recent Bubblegum transactions from the public RPC and prints every decoded MintV1 instruction. Add the dependencies:
cargo add carbon-core@2.0.0 carbon-bubblegum-decoder@2.0.0 carbon-rpc-transaction-crawler-datasource@2.0.0 carbon-log-metrics@2.0.0 env_logger tokio --features tokio/fulluse {
carbon_core::{
error::CarbonResult, instruction::InstructionProcessorInputType, pipeline::Pipeline,
processor::Processor,
},
carbon_log_metrics::LogMetrics,
carbon_bubblegum_decoder::{instructions::BubblegumInstruction, BubblegumDecoder, PROGRAM_ID},
carbon_rpc_transaction_crawler_datasource::{ConnectionConfig, Filters, RpcTransactionCrawler},
std::sync::Arc,
};
#[tokio::main]
async fn main() -> CarbonResult<()> {
env_logger::init();
// Fetches the program's recent transactions over JSON-RPC, newest first.
let datasource = RpcTransactionCrawler::new(
"https://api.mainnet-beta.solana.com".to_string(),
PROGRAM_ID,
ConnectionConfig::default(),
Filters::new(None, None, None),
None,
);
Pipeline::builder()
.datasource(datasource)
.metrics(Arc::new(LogMetrics::new()))
.instruction(BubblegumDecoder, InstructionLogger)
.build()?
.run()
.await
}
struct InstructionLogger;
impl Processor<InstructionProcessorInputType<'_, BubblegumInstruction>> for InstructionLogger {
async fn process(
&mut self,
input: &InstructionProcessorInputType<'_, BubblegumInstruction>,
) -> CarbonResult<()> {
let signature = input.metadata.transaction_metadata.signature;
if let BubblegumInstruction::MintV1 { data, accounts, .. } = input.decoded_instruction {
println!("mint_v1 {signature}: {data:?} tree_authority={}", accounts.tree_authority);
}
Ok(())
}
}RUST_LOG=info cargo runEach MintV1 instruction prints one line with the transaction signature and the decoded MintV1 data. The public endpoint rate-limits requests, so the first lines can take a while; use your own RPC URL for anything beyond a test. See stream with RPC for the crawler options.
Decode accounts#
The transaction crawler emits transactions only. To decode accounts, use a datasource that emits account updates. This program subscribes to the program's accounts with programSubscribe on the public WebSocket endpoint and prints every decoded TreeConfig account as it changes. Add the datasource and the Solana RPC types it takes:
cargo add carbon-rpc-program-subscribe-datasource@2.0.0 solana-client@4.2.2use {
carbon_core::{
account::AccountProcessorInputType, error::CarbonResult, pipeline::Pipeline,
processor::Processor,
},
carbon_log_metrics::LogMetrics,
carbon_bubblegum_decoder::{accounts::BubblegumAccount, BubblegumDecoder, PROGRAM_ID},
carbon_rpc_program_subscribe_datasource::{Filters, RpcProgramSubscribe},
solana_client::rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig, UiAccountEncoding},
std::sync::Arc,
};
#[tokio::main]
async fn main() -> CarbonResult<()> {
env_logger::init();
// Streams every change to an account owned by the program (programSubscribe).
let config = RpcProgramAccountsConfig {
account_config: RpcAccountInfoConfig {
encoding: Some(UiAccountEncoding::Base64),
..Default::default()
},
..Default::default()
};
let datasource = RpcProgramSubscribe::new(
"wss://api.mainnet-beta.solana.com".to_string(),
Filters::new(PROGRAM_ID, Some(config)),
);
Pipeline::builder()
.datasource(datasource)
.metrics(Arc::new(LogMetrics::new()))
.account(BubblegumDecoder, AccountLogger)
.build()?
.run()
.await
}
struct AccountLogger;
impl Processor<AccountProcessorInputType<'_, BubblegumAccount>> for AccountLogger {
async fn process(
&mut self,
input: &AccountProcessorInputType<'_, BubblegumAccount>,
) -> CarbonResult<()> {
if let BubblegumAccount::TreeConfig(tree_config) = &input.decoded_account.data {
println!("tree_config {}: {tree_config:?}", input.metadata.pubkey);
}
Ok(())
}
}RUST_LOG=info cargo runEach update to a TreeConfig account prints its address and decoded fields; the program runs until you stop it. Cargo resolves solana-client to 4.2.2, the exact version the datasource pins, so both use the same RpcProgramAccountsConfig type. To load every existing account once instead of streaming changes, see load account state.
Instructions#
Variants of BubblegumInstruction. Each is BubblegumInstruction::, where data and accounts are the types listed under the variant, exported from carbon_. Discriminators are the leading bytes of the instruction data, in hex.
How an instruction decodes. The decoder returns a variant only when all of these hold; otherwise the instruction is skipped and no processor is called:
- The instruction's program ID is
BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY. - The data starts with the variant's discriminator, and the rest deserializes into its data type.
- The instruction has at least as many accounts as the variant requires (the "Required accounts" count under each variant).
Accounts. They are matched by position, in the order listed. An account marked optional is None only when the instruction ends before it; Anchor programs pass the program ID as a placeholder for an omitted optional account, so check for Some(PROGRAM_ too. Accounts after the listed ones are in accounts. as AccountMetas. The decoder doesn't record whether an account signed or was writable: read that from input. and ., which follow the same order. It doesn't check signer, writable, owner or PDA constraints either; the program enforced those when the transaction executed, so a decoded instruction from a successful transaction already satisfied them.
Burn#
Discriminator 746e1d386bdb2a5d · data Burn · accounts BurnInstructionAccounts.
| Field | Type |
|---|---|
root | [u8; 32] |
data_hash | [u8; 32] |
creator_ | [u8; 32] |
nonce | u64 |
index | u32 |
Required accounts: 7; extras go to remaining.
Fields of BurnInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | leaf_owner | Pubkey |
| 2 | leaf_ | Pubkey |
| 3 | merkle_tree | Pubkey |
| 4 | log_wrapper | Pubkey |
| 5 | compression_ | Pubkey |
| 6 | system_ | Pubkey |
| 7… | remaining | Vec< |
CancelRedeem#
Discriminator 6f4ce83227af30f2 · data CancelRedeem · accounts CancelRedeemInstructionAccounts.
| Field | Type |
|---|---|
root | [u8; 32] |
Required accounts: 7; extras go to remaining.
Fields of CancelRedeemInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | leaf_owner | Pubkey |
| 2 | merkle_tree | Pubkey |
| 3 | voucher | Pubkey |
| 4 | log_wrapper | Pubkey |
| 5 | compression_ | Pubkey |
| 6 | system_ | Pubkey |
| 7… | remaining | Vec< |
CreateTree#
Discriminator a553888e59ca2fdc · data CreateTree · accounts CreateTreeInstructionAccounts.
| Field | Type |
|---|---|
max_depth | u32 |
max_ | u32 |
public | Option< |
Required accounts: 7; extras go to remaining.
Fields of CreateTreeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | merkle_tree | Pubkey |
| 2 | payer | Pubkey |
| 3 | tree_ | Pubkey |
| 4 | log_wrapper | Pubkey |
| 5 | compression_ | Pubkey |
| 6 | system_ | Pubkey |
| 7… | remaining | Vec< |
DecompressV1#
Discriminator 36554c46e4faa451 · data DecompressV1 · accounts DecompressV1InstructionAccounts.
| Field | Type |
|---|---|
metadata | MetadataArgs |
Required accounts: 13; extras go to remaining.
Fields of DecompressV1InstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | voucher | Pubkey |
| 1 | leaf_owner | Pubkey |
| 2 | token_ | Pubkey |
| 3 | mint | Pubkey |
| 4 | mint_ | Pubkey |
| 5 | metadata | Pubkey |
| 6 | master_ | Pubkey |
| 7 | system_ | Pubkey |
| 8 | sysvar_rent | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | associated_ | Pubkey |
| 12 | log_wrapper | Pubkey |
| 13… | remaining | Vec< |
Delegate#
Discriminator 5a934bb255580489 · data Delegate · accounts DelegateInstructionAccounts.
| Field | Type |
|---|---|
root | [u8; 32] |
data_hash | [u8; 32] |
creator_ | [u8; 32] |
nonce | u64 |
index | u32 |
Required accounts: 8; extras go to remaining.
Fields of DelegateInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | leaf_owner | Pubkey |
| 2 | previous_ | Pubkey |
| 3 | new_ | Pubkey |
| 4 | merkle_tree | Pubkey |
| 5 | log_wrapper | Pubkey |
| 6 | compression_ | Pubkey |
| 7 | system_ | Pubkey |
| 8… | remaining | Vec< |
MintToCollectionV1#
Discriminator 9912b22fc59e560f · data MintToCollectionV1 · accounts MintToCollectionV1InstructionAccounts.
| Field | Type |
|---|---|
metadata_ | MetadataArgs |
Required accounts: 16; extras go to remaining.
Fields of MintToCollectionV1InstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | leaf_owner | Pubkey |
| 2 | leaf_ | Pubkey |
| 3 | merkle_tree | Pubkey |
| 4 | payer | Pubkey |
| 5 | tree_ | Pubkey |
| 6 | collection_ | Pubkey |
| 7 | collection_ | Pubkey |
| 8 | collection_ | Pubkey |
| 9 | collection_ | Pubkey |
| 10 | edition_ | Pubkey |
| 11 | bubblegum_ | Pubkey |
| 12 | log_wrapper | Pubkey |
| 13 | compression_ | Pubkey |
| 14 | token_ | Pubkey |
| 15 | system_ | Pubkey |
| 16… | remaining | Vec< |
MintV1#
Discriminator 9162c076b8937668 · data MintV1 · accounts MintV1InstructionAccounts.
| Field | Type |
|---|---|
message | MetadataArgs |
Required accounts: 9; extras go to remaining.
Fields of MintV1InstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | leaf_owner | Pubkey |
| 2 | leaf_ | Pubkey |
| 3 | merkle_tree | Pubkey |
| 4 | payer | Pubkey |
| 5 | tree_ | Pubkey |
| 6 | log_wrapper | Pubkey |
| 7 | compression_ | Pubkey |
| 8 | system_ | Pubkey |
| 9… | remaining | Vec< |
Redeem#
Discriminator b80c569546c461e1 · data Redeem · accounts RedeemInstructionAccounts.
| Field | Type |
|---|---|
root | [u8; 32] |
data_hash | [u8; 32] |
creator_ | [u8; 32] |
nonce | u64 |
index | u32 |
Required accounts: 8; extras go to remaining.
Fields of RedeemInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | leaf_owner | Pubkey |
| 2 | leaf_ | Pubkey |
| 3 | merkle_tree | Pubkey |
| 4 | voucher | Pubkey |
| 5 | log_wrapper | Pubkey |
| 6 | compression_ | Pubkey |
| 7 | system_ | Pubkey |
| 8… | remaining | Vec< |
SetAndVerifyCollection#
Discriminator ebf279d89eeab4ea · data SetAndVerifyCollection · accounts SetAndVerifyCollectionInstructionAccounts.
| Field | Type |
|---|---|
root | [u8; 32] |
data_hash | [u8; 32] |
creator_ | [u8; 32] |
nonce | u64 |
index | u32 |
message | MetadataArgs |
collection | Pubkey |
Required accounts: 16; extras go to remaining.
Fields of SetAndVerifyCollectionInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | leaf_owner | Pubkey |
| 2 | leaf_ | Pubkey |
| 3 | merkle_tree | Pubkey |
| 4 | payer | Pubkey |
| 5 | tree_ | Pubkey |
| 6 | collection_ | Pubkey |
| 7 | collection_ | Pubkey |
| 8 | collection_ | Pubkey |
| 9 | collection_ | Pubkey |
| 10 | edition_ | Pubkey |
| 11 | bubblegum_ | Pubkey |
| 12 | log_wrapper | Pubkey |
| 13 | compression_ | Pubkey |
| 14 | token_ | Pubkey |
| 15 | system_ | Pubkey |
| 16… | remaining | Vec< |
SetDecompressibleState#
Discriminator 52689806956f640d · data SetDecompressibleState · accounts SetDecompressibleStateInstructionAccounts.
| Field | Type |
|---|---|
decompressable_ | DecompressibleState |
Required accounts: 2; extras go to remaining.
Fields of SetDecompressibleStateInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | tree_ | Pubkey |
| 2… | remaining | Vec< |
SetTreeDelegate#
Discriminator fd764225be319a66 · data SetTreeDelegate · accounts SetTreeDelegateInstructionAccounts.
No data fields.
Required accounts: 5; extras go to remaining.
Fields of SetTreeDelegateInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | tree_ | Pubkey |
| 2 | new_ | Pubkey |
| 3 | merkle_tree | Pubkey |
| 4 | system_ | Pubkey |
| 5… | remaining | Vec< |
Transfer#
Discriminator a334c8e78c0345ba · data Transfer · accounts TransferInstructionAccounts.
| Field | Type |
|---|---|
root | [u8; 32] |
data_hash | [u8; 32] |
creator_ | [u8; 32] |
nonce | u64 |
index | u32 |
Required accounts: 8; extras go to remaining.
Fields of TransferInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | leaf_owner | Pubkey |
| 2 | leaf_ | Pubkey |
| 3 | new_ | Pubkey |
| 4 | merkle_tree | Pubkey |
| 5 | log_wrapper | Pubkey |
| 6 | compression_ | Pubkey |
| 7 | system_ | Pubkey |
| 8… | remaining | Vec< |
UnverifyCollection#
Discriminator fafb2a6a2989baa8 · data UnverifyCollection · accounts UnverifyCollectionInstructionAccounts.
| Field | Type |
|---|---|
root | [u8; 32] |
data_hash | [u8; 32] |
creator_ | [u8; 32] |
nonce | u64 |
index | u32 |
message | MetadataArgs |
Required accounts: 16; extras go to remaining.
Fields of UnverifyCollectionInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | leaf_owner | Pubkey |
| 2 | leaf_ | Pubkey |
| 3 | merkle_tree | Pubkey |
| 4 | payer | Pubkey |
| 5 | tree_ | Pubkey |
| 6 | collection_ | Pubkey |
| 7 | collection_ | Pubkey |
| 8 | collection_ | Pubkey |
| 9 | collection_ | Pubkey |
| 10 | edition_ | Pubkey |
| 11 | bubblegum_ | Pubkey |
| 12 | log_wrapper | Pubkey |
| 13 | compression_ | Pubkey |
| 14 | token_ | Pubkey |
| 15 | system_ | Pubkey |
| 16… | remaining | Vec< |
UnverifyCreator#
Discriminator 6bb2392769737098 · data UnverifyCreator · accounts UnverifyCreatorInstructionAccounts.
| Field | Type |
|---|---|
root | [u8; 32] |
data_hash | [u8; 32] |
creator_ | [u8; 32] |
nonce | u64 |
index | u32 |
message | MetadataArgs |
Required accounts: 9; extras go to remaining.
Fields of UnverifyCreatorInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | leaf_owner | Pubkey |
| 2 | leaf_ | Pubkey |
| 3 | merkle_tree | Pubkey |
| 4 | payer | Pubkey |
| 5 | creator | Pubkey |
| 6 | log_wrapper | Pubkey |
| 7 | compression_ | Pubkey |
| 8 | system_ | Pubkey |
| 9… | remaining | Vec< |
UpdateMetadata#
Discriminator aab62bef614ee1ba · data UpdateMetadata · accounts UpdateMetadataInstructionAccounts.
| Field | Type |
|---|---|
root | [u8; 32] |
nonce | u64 |
index | u32 |
current_ | MetadataArgs |
update_args | UpdateArgs |
Required accounts: 13; extras go to remaining.
Fields of UpdateMetadataInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | authority | Pubkey |
| 2 | collection_ | Option< |
| 3 | collection_ | Option< |
| 4 | collection_ | Option< |
| 5 | leaf_owner | Pubkey |
| 6 | leaf_ | Pubkey |
| 7 | payer | Pubkey |
| 8 | merkle_tree | Pubkey |
| 9 | log_wrapper | Pubkey |
| 10 | compression_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | system_ | Pubkey |
| 13… | remaining | Vec< |
VerifyCollection#
Discriminator 387165fd4f377aa9 · data VerifyCollection · accounts VerifyCollectionInstructionAccounts.
| Field | Type |
|---|---|
root | [u8; 32] |
data_hash | [u8; 32] |
creator_ | [u8; 32] |
nonce | u64 |
index | u32 |
message | MetadataArgs |
Required accounts: 16; extras go to remaining.
Fields of VerifyCollectionInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | leaf_owner | Pubkey |
| 2 | leaf_ | Pubkey |
| 3 | merkle_tree | Pubkey |
| 4 | payer | Pubkey |
| 5 | tree_ | Pubkey |
| 6 | collection_ | Pubkey |
| 7 | collection_ | Pubkey |
| 8 | collection_ | Pubkey |
| 9 | collection_ | Pubkey |
| 10 | edition_ | Pubkey |
| 11 | bubblegum_ | Pubkey |
| 12 | log_wrapper | Pubkey |
| 13 | compression_ | Pubkey |
| 14 | token_ | Pubkey |
| 15 | system_ | Pubkey |
| 16… | remaining | Vec< |
VerifyCreator#
Discriminator 34116084470455c2 · data VerifyCreator · accounts VerifyCreatorInstructionAccounts.
| Field | Type |
|---|---|
root | [u8; 32] |
data_hash | [u8; 32] |
creator_ | [u8; 32] |
nonce | u64 |
index | u32 |
message | MetadataArgs |
Required accounts: 9; extras go to remaining.
Fields of VerifyCreatorInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | tree_ | Pubkey |
| 1 | leaf_owner | Pubkey |
| 2 | leaf_ | Pubkey |
| 3 | merkle_tree | Pubkey |
| 4 | payer | Pubkey |
| 5 | creator | Pubkey |
| 6 | log_wrapper | Pubkey |
| 7 | compression_ | Pubkey |
| 8 | system_ | Pubkey |
| 9… | remaining | Vec< |
Accounts#
Variants of BubblegumAccount. Each wraps a boxed struct from carbon_. decode_ only considers accounts owned by PROGRAM_ID and returns the first variant that matches.
TreeConfig#
Discriminator 7af5aff8ab2200cf · accounts::.
| Field | Type |
|---|---|
tree_ | Pubkey |
tree_ | Pubkey |
total_ | u64 |
num_minted | u64 |
is_public | bool |
is_ | DecompressibleState |
Voucher#
Discriminator bfcc95ead5a50d41 · accounts::.
| Field | Type |
|---|---|
leaf_schema | LeafSchema |
index | u32 |
merkle_tree | Pubkey |
Types#
Types used by the instructions, accounts and events above, exported from carbon_.
BubblegumEventType#
Enum types::.
| Variant |
|---|
Uninitialized |
LeafSchemaEvent |
Collection#
Struct types::.
| Field | Type |
|---|---|
verified | bool |
key | Pubkey |
Creator#
Struct types::.
| Field | Type |
|---|---|
address | Pubkey |
verified | bool |
share | u8 |
DecompressibleState#
Enum types::.
| Variant |
|---|
Enabled |
Disabled |
LeafSchema#
Enum types::.
| Variant | Fields |
|---|---|
V1 | id: Pubkey, owner: Pubkey, delegate: Pubkey, nonce: u64, data_hash: [u8; 32], creator_: [u8; 32] |
MetadataArgs#
Struct types::.
| Field | Type |
|---|---|
name | String |
symbol | String |
uri | String |
seller_ | u16 |
primary_ | bool |
is_mutable | bool |
edition_ | Option<u8> |
token_ | Option< |
collection | Option< |
uses | Option< |
token_ | TokenProgramVersion |
creators | Vec< |
TokenProgramVersion#
Enum types::.
| Variant |
|---|
Original |
Token2022 |
TokenStandard#
Enum types::.
| Variant |
|---|
NonFungible |
FungibleAsset |
Fungible |
NonFungibleEdition |
UpdateArgs#
Struct types::.
| Field | Type |
|---|---|
name | Option< |
symbol | Option< |
uri | Option< |
creators | Option< |
seller_ | Option<u16> |
primary_ | Option< |
is_mutable | Option< |
UseMethod#
Enum types::.
| Variant |
|---|
Burn |
Multiple |
Single |
Uses#
Struct types::Uses.
| Field | Type |
|---|---|
use_method | UseMethod |
remaining | u64 |
total | u64 |
Version#
Enum types::.
| Variant |
|---|
V1 |