Moonshot decoder

Decode Moonshot instructions, accounts and events in Rust with carbon-moonshot-decoder 2.0.0. Program ID MoonCVVNZFSYkqNXP6bxHLPL6QQJiMagDL3qcqUQTrG.

On this page

carbon-moonshot-decoder decodes the instructions, accounts and events of the Moonshot program (MoonCVVNZFSYkqNXP6bxHLPL6QQJiMagDL3qcqUQTrG): 6 instructions, 2 account types, 2 events. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.

Cratecarbon-moonshot-decoder 2.0.0
Installcargo add carbon-moonshot-decoder@2.0.0
Program IDMoonCVVNZFSYkqNXP6bxHLPL6QQJiMagDL3qcqUQTrG (carbon_moonshot_decoder::PROGRAM_ID)
CategoryLaunchpads
Decodercarbon_moonshot_decoder::MoonshotDecoder
Instruction enuminstructions::MoonshotInstruction
Account enumaccounts::MoonshotAccount
Event enuminstructions::CpiEvent
Featuresserde, postgres, graphql (none enabled by default)
API docsdocs.rs/carbon-moonshot-decoder/2.0.0
Sourcedecoders/moonshot-decoder

Other launchpad decoders: Boop, Meteora DBC, Pump.fun, Raydium Launchpad, Vertigo, Virtuals, Wavebreak. To decode several in one pipeline, see launchpad 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 Moonshot transactions from the public RPC and prints every decoded Buy instruction. Add the dependencies:

Terminal
cargo add carbon-core@2.0.0 carbon-moonshot-decoder@2.0.0 carbon-rpc-transaction-crawler-datasource@2.0.0 carbon-log-metrics@2.0.0 env_logger tokio --features tokio/full
src/main.rs
use {
    carbon_core::{
        error::CarbonResult, instruction::InstructionProcessorInputType, pipeline::Pipeline,
        processor::Processor,
    },
    carbon_log_metrics::LogMetrics,
    carbon_moonshot_decoder::{instructions::MoonshotInstruction, MoonshotDecoder, 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(MoonshotDecoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

impl Processor<InstructionProcessorInputType<'_, MoonshotInstruction>> for InstructionLogger {
    async fn process(
        &mut self,
        input: &InstructionProcessorInputType<'_, MoonshotInstruction>,
    ) -> CarbonResult<()> {
        let signature = input.metadata.transaction_metadata.signature;
        if let MoonshotInstruction::Buy { data, accounts, .. } = input.decoded_instruction {
            println!("buy {signature}: {data:?} sender={}", accounts.sender);
        }
        Ok(())
    }
}
Terminal
RUST_LOG=info cargo run

Each Buy instruction prints one line with the transaction signature and the decoded Buy 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.

Events published with Anchor's emit_cpi! arrive as the CpiEvent instruction. Match them with MoonshotInstruction::CpiEvent { data: CpiEvent::TradeEvent(event), .. } (import instructions::CpiEvent); see Events. If CpiEvent never arrives, the program logs its events with emit! instead: decode them with decode_log_events.

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 ConfigAccount account as it changes. Add the datasource and the Solana RPC types it takes:

Terminal
cargo add carbon-rpc-program-subscribe-datasource@2.0.0 solana-client@4.2.2
src/main.rs
use {
    carbon_core::{
        account::AccountProcessorInputType, error::CarbonResult, pipeline::Pipeline,
        processor::Processor,
    },
    carbon_log_metrics::LogMetrics,
    carbon_moonshot_decoder::{accounts::MoonshotAccount, MoonshotDecoder, 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(MoonshotDecoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

impl Processor<AccountProcessorInputType<'_, MoonshotAccount>> for AccountLogger {
    async fn process(
        &mut self,
        input: &AccountProcessorInputType<'_, MoonshotAccount>,
    ) -> CarbonResult<()> {
        if let MoonshotAccount::ConfigAccount(config_account) = &input.decoded_account.data {
            println!("config_account {}: {config_account:?}", input.metadata.pubkey);
        }
        Ok(())
    }
}
Terminal
RUST_LOG=info cargo run

Each update to a ConfigAccount 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 MoonshotInstruction. Each is MoonshotInstruction::<Variant> { program_id, data, accounts }, where data and accounts are the types listed under the variant, exported from carbon_moonshot_decoder::instructions. 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:

  1. The instruction's program ID is MoonCVVNZFSYkqNXP6bxHLPL6QQJiMagDL3qcqUQTrG.
  2. The data starts with the variant's discriminator, and the rest deserializes into its data type.
  3. 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_ID) too. Accounts after the listed ones are in accounts.remaining as AccountMetas. The decoder doesn't record whether an account signed or was writable: read that from input.raw_instruction.accounts[i].is_signer and .is_writable, 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.

Buy#

Discriminator 66063d1201daebea · data Buy · accounts BuyInstructionAccounts.

FieldType
dataTradeParams

Required accounts: 11; extras go to remaining.

Fields of BuyInstructionAccounts, in account order:

#FieldType
0senderPubkey
1sender_token_accountPubkey
2curve_accountPubkey
3curve_token_accountPubkey
4dex_feePubkey
5helio_feePubkey
6mintPubkey
7config_accountPubkey
8token_programPubkey
9associated_token_programPubkey
10system_programPubkey
11…remainingVec<AccountMeta>

ConfigInit#

Discriminator 0deca4ad6afda4b9 · data ConfigInit · accounts ConfigInitInstructionAccounts.

FieldType
dataConfigParams

Required accounts: 3; extras go to remaining.

Fields of ConfigInitInstructionAccounts, in account order:

#FieldType
0config_authorityPubkey
1config_accountPubkey
2system_programPubkey
3…remainingVec<AccountMeta>

ConfigUpdate#

Discriminator 50256d88528759f1 · data ConfigUpdate · accounts ConfigUpdateInstructionAccounts.

FieldType
dataConfigParams

Required accounts: 2; extras go to remaining.

Fields of ConfigUpdateInstructionAccounts, in account order:

#FieldType
0config_authorityPubkey
1config_accountPubkey
2…remainingVec<AccountMeta>

MigrateFunds#

Discriminator 2ae50ae7bd3ec1ae · data MigrateFunds · accounts MigrateFundsInstructionAccounts.

No data fields.

Required accounts: 12; extras go to remaining.

Fields of MigrateFundsInstructionAccounts, in account order:

#FieldType
0backend_authorityPubkey
1migration_authorityPubkey
2curve_accountPubkey
3curve_token_accountPubkey
4migration_authority_token_accountPubkey
5mintPubkey
6dex_fee_accountPubkey
7helio_fee_accountPubkey
8config_accountPubkey
9system_programPubkey
10token_programPubkey
11associated_token_programPubkey
12…remainingVec<AccountMeta>

Sell#

Discriminator 33e685a4017f83ad · data Sell · accounts SellInstructionAccounts.

FieldType
dataTradeParams

Required accounts: 11; extras go to remaining.

Fields of SellInstructionAccounts, in account order:

#FieldType
0senderPubkey
1sender_token_accountPubkey
2curve_accountPubkey
3curve_token_accountPubkey
4dex_feePubkey
5helio_feePubkey
6mintPubkey
7config_accountPubkey
8token_programPubkey
9associated_token_programPubkey
10system_programPubkey
11…remainingVec<AccountMeta>

TokenMint#

Discriminator 032ca4b87b0df5b3 · data TokenMint · accounts TokenMintInstructionAccounts.

FieldType
mint_paramsTokenMintParams

Required accounts: 11; extras go to remaining.

Fields of TokenMintInstructionAccounts, in account order:

#FieldType
0senderPubkey
1backend_authorityPubkey
2curve_accountPubkey
3mintPubkey
4mint_metadataPubkey
5curve_token_accountPubkey
6config_accountPubkey
7token_programPubkey
8associated_token_programPubkey
9mpl_token_metadataPubkey
10system_programPubkey
11…remainingVec<AccountMeta>

CpiEvent#

Anchor self-CPI that carries one of the program's events. data is the CpiEvent enum.

Discriminator e445a52e51cb9a1d · data CpiEvent · accounts CpiEventInstructionAccounts.

Required accounts: 2; extras go to remaining.

Fields of CpiEventInstructionAccounts, in account order:

#FieldType
0programPubkey
1event_authorityPubkey
2…remainingVec<AccountMeta>

Accounts#

Variants of MoonshotAccount. Each wraps a boxed struct from carbon_moonshot_decoder::accounts::<module>. decode_account only considers accounts owned by PROGRAM_ID and returns the first variant that matches.

ConfigAccount#

Discriminator bdff6146babd1866 · accounts::config_account::ConfigAccount.

FieldType
migration_authorityPubkey
backend_authorityPubkey
config_authorityPubkey
helio_feePubkey
dex_feePubkey
fee_bpsu16
dex_fee_shareu8
migration_feeu64
marketcap_thresholdu64
marketcap_currencyCurrency
min_supported_decimal_placesu8
max_supported_decimal_placesu8
min_supported_token_supplyu64
max_supported_token_supplyu64
bumpu8
coef_bu32

CurveAccount#

Discriminator 085b531c84d8f816 · accounts::curve_account::CurveAccount.

FieldType
total_supplyu64
curve_amountu64
mintPubkey
decimalsu8
collateral_currencyCurrency
curve_typeCurveType
marketcap_thresholdu64
marketcap_currencyCurrency
migration_feeu64
coef_bu32
bumpu8
migration_targetMigrationTarget

Events#

Variants of instructions::CpiEvent, decoded from the CpiEvent instruction. Each wraps a struct from carbon_moonshot_decoder::events::<module>. The discriminator is the 8-byte event discriminator that follows the e445a52e51cb9a1d CPI-event tag.

TradeEvent#

Discriminator bddb7fd34ee661ee · events::trade_event::TradeEventEvent.

FieldType
amountu64
collateral_amountu64
dex_feeu64
helio_feeu64
allocationu64
curvePubkey
cost_tokenPubkey
senderPubkey
r#typeTradeType
labelString

MigrationEvent#

Discriminator ffca4c935be74916 · events::migration_event::MigrationEventEvent.

FieldType
tokens_migratedu64
tokens_burnedu64
collateral_migratedu64
feeu64
labelString

Types#

Types used by the instructions, accounts and events above, exported from carbon_moonshot_decoder::types.

ConfigParams#

Struct types::ConfigParams.

FieldType
migration_authorityOption<Pubkey>
backend_authorityOption<Pubkey>
config_authorityOption<Pubkey>
helio_feeOption<Pubkey>
dex_feeOption<Pubkey>
fee_bpsOption<u16>
dex_fee_shareOption<u8>
migration_feeOption<u64>
marketcap_thresholdOption<u64>
marketcap_currencyOption<u8>
min_supported_decimal_placesOption<u8>
max_supported_decimal_placesOption<u8>
min_supported_token_supplyOption<u64>
max_supported_token_supplyOption<u64>
coef_bOption<u32>

Currency#

Enum types::Currency.

Variant
Sol

CurveType#

Enum types::CurveType.

Variant
LinearV1
ConstantProductV1

FixedSide#

Enum types::FixedSide.

Variant
ExactIn
ExactOut

MigrationEvent#

Struct types::MigrationEvent. Same fields as the MigrationEvent event.

MigrationTarget#

Enum types::MigrationTarget.

Variant
Raydium
Meteora

TokenMintParams#

Struct types::TokenMintParams.

FieldType
nameString
symbolString
uriString
decimalsu8
collateral_currencyu8
amountu64
curve_typeu8
migration_targetu8

TradeEvent#

Struct types::TradeEvent. Same fields as the TradeEvent event.

TradeParams#

Struct types::TradeParams.

FieldType
token_amountu64
collateral_amountu64
fixed_sideu8
slippage_bpsu64

TradeType#

Enum types::TradeType.

Variant
Buy
Sell

Generated from the crate’s source at Carbon v2.0.0, so it always matches the published code. Spotted a problem? Report it; edits to this page itself are overwritten on the next release.

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.