Circle CCTP Message Transmitter v2 decoder

Decode Circle CCTP Message Transmitter v2 instructions, accounts and events in Rust with the carbon-circle-message-transmitter-v2-decoder crate.

On this page

carbon-circle-message-transmitter-v2-decoder decodes the instructions, accounts and events of the Circle CCTP Message Transmitter v2 program (CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC): 15 instructions, 3 account types, 11 events. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.

Cratecarbon-circle-message-transmitter-v2-decoder 2.0.0
Installcargo add carbon-circle-message-transmitter-v2-decoder@2.0.0
Program IDCCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC (carbon_circle_message_transmitter_v2_decoder::PROGRAM_ID)
CategoryBridges & messaging
Decodercarbon_circle_message_transmitter_v2_decoder::CircleMessageTransmitterV2Decoder
Instruction enuminstructions::CircleMessageTransmitterV2Instruction
Account enumaccounts::CircleMessageTransmitterV2Account
Event enuminstructions::CpiEvent
Featuresserde, postgres, graphql (none enabled by default)
API docsdocs.rs/carbon-circle-message-transmitter-v2-decoder/2.0.0
Sourcedecoders/circle-message-transmitter-v2-decoder

Other bridge and messaging decoders: Circle CCTP Token Messenger v2. To decode several in one pipeline, see bridge and messaging 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 Circle CCTP Message Transmitter v2 transactions from the public RPC and prints every decoded ReceiveMessage instruction. Add the dependencies:

Terminal
cargo add carbon-core@2.0.0 carbon-circle-message-transmitter-v2-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_circle_message_transmitter_v2_decoder::{
        instructions::CircleMessageTransmitterV2Instruction, CircleMessageTransmitterV2Decoder,
        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(CircleMessageTransmitterV2Decoder, InstructionLogger)
        .build()?
        .run()
        .await
}

struct InstructionLogger;

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

Each ReceiveMessage instruction prints one line with the transaction signature and the decoded ReceiveMessage 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 CircleMessageTransmitterV2Instruction::CpiEvent { data: CpiEvent::AttesterDisabled(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 MessageSent 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_circle_message_transmitter_v2_decoder::{
        accounts::CircleMessageTransmitterV2Account, CircleMessageTransmitterV2Decoder, 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(CircleMessageTransmitterV2Decoder, AccountLogger)
        .build()?
        .run()
        .await
}

struct AccountLogger;

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

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

AcceptOwnership#

Discriminator ac172b0deed55596 · data AcceptOwnership · accounts AcceptOwnershipInstructionAccounts.

FieldType
paramsAcceptOwnershipParams

Required accounts: 4; extras go to remaining.

Fields of AcceptOwnershipInstructionAccounts, in account order:

#FieldType
0pending_ownerPubkey
1message_transmitterPubkey
2event_authorityPubkey
3programPubkey
4…remainingVec<AccountMeta>

DisableAttester#

Discriminator 3dab835fac0fe3e5 · data DisableAttester · accounts DisableAttesterInstructionAccounts.

FieldType
paramsDisableAttesterParams

Required accounts: 6; extras go to remaining.

Fields of DisableAttesterInstructionAccounts, in account order:

#FieldType
0payerPubkey
1attester_managerPubkey
2message_transmitterPubkey
3system_programPubkey
4event_authorityPubkey
5programPubkey
6…remainingVec<AccountMeta>

EnableAttester#

Discriminator 020bc173059404c6 · data EnableAttester · accounts EnableAttesterInstructionAccounts.

FieldType
paramsEnableAttesterParams

Required accounts: 6; extras go to remaining.

Fields of EnableAttesterInstructionAccounts, in account order:

#FieldType
0payerPubkey
1attester_managerPubkey
2message_transmitterPubkey
3system_programPubkey
4event_authorityPubkey
5programPubkey
6…remainingVec<AccountMeta>

Initialize#

Discriminator afaf6d1f0d989bed · data Initialize · accounts InitializeInstructionAccounts.

FieldType
paramsInitializeParams

Required accounts: 8; extras go to remaining.

Fields of InitializeInstructionAccounts, in account order:

#FieldType
0payerPubkey
1upgrade_authorityPubkey
2message_transmitterPubkey
3message_transmitter_program_dataPubkey
4message_transmitter_programPubkey
5system_programPubkey
6event_authorityPubkey
7programPubkey
8…remainingVec<AccountMeta>

IsNonceUsed#

Discriminator 90486b9423da1fbb · data IsNonceUsed · accounts IsNonceUsedInstructionAccounts.

No data fields.

Required accounts: 1; extras go to remaining.

Fields of IsNonceUsedInstructionAccounts, in account order:

#FieldType
0used_noncePubkey
1…remainingVec<AccountMeta>

Pause#

Discriminator d316ddfb4a79c12f · data Pause · accounts PauseInstructionAccounts.

FieldType
paramsPauseParams

Required accounts: 4; extras go to remaining.

Fields of PauseInstructionAccounts, in account order:

#FieldType
0pauserPubkey
1message_transmitterPubkey
2event_authorityPubkey
3programPubkey
4…remainingVec<AccountMeta>

ReceiveMessage#

Discriminator 26907fe11fe1ee19 · data ReceiveMessage · accounts ReceiveMessageInstructionAccounts.

FieldType
paramsReceiveMessageParams

Required accounts: 9; extras go to remaining.

Fields of ReceiveMessageInstructionAccounts, in account order:

#FieldType
0payerPubkey
1callerPubkey
2authority_pdaPubkey
3message_transmitterPubkey
4used_noncePubkey
5receiverPubkey
6system_programPubkey
7event_authorityPubkey
8programPubkey
9…remainingVec<AccountMeta>

ReclaimEventAccount#

Discriminator 5ec6b49f83ec0fae · data ReclaimEventAccount · accounts ReclaimEventAccountInstructionAccounts.

Required accounts: 3; extras go to remaining.

Fields of ReclaimEventAccountInstructionAccounts, in account order:

#FieldType
0payeePubkey
1message_transmitterPubkey
2message_sent_event_dataPubkey
3…remainingVec<AccountMeta>

SendMessage#

Discriminator 392822b2bd0a411a · data SendMessage · accounts SendMessageInstructionAccounts.

FieldType
paramsSendMessageParams

Required accounts: 6; extras go to remaining.

Fields of SendMessageInstructionAccounts, in account order:

#FieldType
0event_rent_payerPubkey
1sender_authority_pdaPubkey
2message_transmitterPubkey
3message_sent_event_dataPubkey
4sender_programPubkey
5system_programPubkey
6…remainingVec<AccountMeta>

SetMaxMessageBodySize#

Discriminator a8b20875d9a7db1f · data SetMaxMessageBodySize · accounts SetMaxMessageBodySizeInstructionAccounts.

Required accounts: 4; extras go to remaining.

Fields of SetMaxMessageBodySizeInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1message_transmitterPubkey
2event_authorityPubkey
3programPubkey
4…remainingVec<AccountMeta>

SetSignatureThreshold#

Discriminator a3139aa852d1d6db · data SetSignatureThreshold · accounts SetSignatureThresholdInstructionAccounts.

Required accounts: 4; extras go to remaining.

Fields of SetSignatureThresholdInstructionAccounts, in account order:

#FieldType
0attester_managerPubkey
1message_transmitterPubkey
2event_authorityPubkey
3programPubkey
4…remainingVec<AccountMeta>

TransferOwnership#

Discriminator 41b1d749352d632f · data TransferOwnership · accounts TransferOwnershipInstructionAccounts.

Required accounts: 4; extras go to remaining.

Fields of TransferOwnershipInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1message_transmitterPubkey
2event_authorityPubkey
3programPubkey
4…remainingVec<AccountMeta>

Unpause#

Discriminator a99004260a8dbcff · data Unpause · accounts UnpauseInstructionAccounts.

FieldType
paramsUnpauseParams

Required accounts: 4; extras go to remaining.

Fields of UnpauseInstructionAccounts, in account order:

#FieldType
0pauserPubkey
1message_transmitterPubkey
2event_authorityPubkey
3programPubkey
4…remainingVec<AccountMeta>

UpdateAttesterManager#

Discriminator aff5b26855b34710 · data UpdateAttesterManager · accounts UpdateAttesterManagerInstructionAccounts.

Required accounts: 4; extras go to remaining.

Fields of UpdateAttesterManagerInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1message_transmitterPubkey
2event_authorityPubkey
3programPubkey
4…remainingVec<AccountMeta>

UpdatePauser#

Discriminator 8cabd38439c910fe · data UpdatePauser · accounts UpdatePauserInstructionAccounts.

FieldType
paramsUpdatePauserParams

Required accounts: 4; extras go to remaining.

Fields of UpdatePauserInstructionAccounts, in account order:

#FieldType
0ownerPubkey
1message_transmitterPubkey
2event_authorityPubkey
3programPubkey
4…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 CircleMessageTransmitterV2Account. Each wraps a boxed struct from carbon_circle_message_transmitter_v2_decoder::accounts::<module>. decode_account only considers accounts owned by PROGRAM_ID and returns the first variant that matches.

MessageSent#

Discriminator 83648538a6e1973c · accounts::message_sent::MessageSent.

FieldType
rent_payerPubkey
created_ati64
messageVec<u8>

MessageTransmitter#

Discriminator 4728b48e13cb23fc · accounts::message_transmitter::MessageTransmitter.

FieldType
ownerPubkey
pending_ownerPubkey
attester_managerPubkey
pauserPubkey
pausedbool
local_domainu32
versionu32
signature_thresholdu32
enabled_attestersVec<Pubkey>
max_message_body_sizeu64

UsedNonce#

Discriminator d4de9dfc8247b3ee · accounts::used_nonce::UsedNonce.

FieldType
is_usedbool

Events#

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

AttesterDisabled#

Discriminator ba88ba0ee50279d3 · events::attester_disabled::AttesterDisabledEvent.

FieldType
attesterPubkey

AttesterEnabled#

Discriminator 58390e8505db3ebe · events::attester_enabled::AttesterEnabledEvent.

FieldType
attesterPubkey

AttesterManagerUpdated#

Discriminator 0561bf6c2cbd4558 · events::attester_manager_updated::AttesterManagerUpdatedEvent.

FieldType
previous_attester_managerPubkey
new_attester_managerPubkey

MaxMessageBodySizeUpdated#

Discriminator 86ce976f890ba0e1 · events::max_message_body_size_updated::MaxMessageBodySizeUpdatedEvent.

FieldType
new_max_message_body_sizeu64

MessageReceived#

Discriminator e7442f4dadf19da6 · events::message_received::MessageReceivedEvent.

FieldType
callerPubkey
source_domainu32
nonce[u8; 32]
senderPubkey
finality_threshold_executedu32
message_bodyVec<u8>

OwnershipTransferStarted#

Discriminator b7fdeff68cb38569 · events::ownership_transfer_started::OwnershipTransferStartedEvent.

FieldType
previous_ownerPubkey
new_ownerPubkey

OwnershipTransferred#

Discriminator ac3dcdb7fa322662 · events::ownership_transferred::OwnershipTransferredEvent.

FieldType
previous_ownerPubkey
new_ownerPubkey

Pause#

Discriminator c2fbe8c4765f6fdb · events::pause::PauseEvent.

No fields.

PauserChanged#

Discriminator 8e9d9e577f087737 · events::pauser_changed::PauserChangedEvent.

FieldType
new_addressPubkey

SignatureThresholdUpdated#

Discriminator 9c6367c80f267abd · events::signature_threshold_updated::SignatureThresholdUpdatedEvent.

FieldType
old_signature_thresholdu32
new_signature_thresholdu32

Unpause#

Discriminator f195685ac788db92 · events::unpause::UnpauseEvent.

No fields.

Types#

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

AcceptOwnershipParams#

Struct types::AcceptOwnershipParams.

No fields.

AttesterDisabled#

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

AttesterEnabled#

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

AttesterManagerUpdated#

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

DisableAttesterParams#

Struct types::DisableAttesterParams.

FieldType
attesterPubkey

EnableAttesterParams#

Struct types::EnableAttesterParams.

FieldType
new_attesterPubkey

InitializeParams#

Struct types::InitializeParams.

FieldType
local_domainu32
attesterPubkey
max_message_body_sizeu64
versionu32

MaxMessageBodySizeUpdated#

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

MessageReceived#

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

OwnershipTransferred#

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

OwnershipTransferStarted#

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

Pause#

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

PauseParams#

Struct types::PauseParams.

No fields.

PauserChanged#

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

ReceiveMessageParams#

Struct types::ReceiveMessageParams.

FieldType
messageVec<u8>
attestationVec<u8>

ReclaimEventAccountParams#

Struct types::ReclaimEventAccountParams.

FieldType
attestationVec<u8>
destination_messageVec<u8>

SendMessageParams#

Struct types::SendMessageParams.

FieldType
destination_domainu32
recipientPubkey
destination_callerPubkey
min_finality_thresholdu32
message_bodyVec<u8>

SetMaxMessageBodySizeParams#

Struct types::SetMaxMessageBodySizeParams.

FieldType
new_max_message_body_sizeu64

SetSignatureThresholdParams#

Struct types::SetSignatureThresholdParams.

FieldType
new_signature_thresholdu32

SignatureThresholdUpdated#

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

TransferOwnershipParams#

Struct types::TransferOwnershipParams.

FieldType
new_ownerPubkey

Unpause#

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

UnpauseParams#

Struct types::UnpauseParams.

No fields.

UpdateAttesterManagerParams#

Struct types::UpdateAttesterManagerParams.

FieldType
new_attester_managerPubkey

UpdatePauserParams#

Struct types::UpdatePauserParams.

FieldType
new_pauserPubkey

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.