Stake Program decoder
Decode Stake Program instructions in Rust with carbon-stake-program-decoder 2.0.0. Program ID Stake11111111111111111111111111111111111111.
On this page
carbon-stake-program-decoder decodes the instructions of the Stake Program program (Stake11111111111111111111111111111111111111): 18 instructions. It decodes no accounts: StakeProgramAccount has no variants. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.
| Crate | carbon-stake-program-decoder 2.0.0 |
| Install | cargo add carbon-stake-program-decoder@2. |
| Program ID | Stake11111111111111111111111111111111111111 (carbon_) |
| Category | Core & SPL |
| Decoder | carbon_ |
| Instruction enum | instructions:: |
| Account enum | accounts:: (no variants) |
| Features | serde, postgres, graphql (none enabled by default) |
| API docs | docs.rs/carbon-stake-program-decoder/2.0.0 |
| Source | decoders/stake-program-decoder |
Other core and SPL decoders: Address Lookup Table, Associated Token Account, SPL Memo, SPL Name Service, SPL Token, System Program, Token-2022. To decode several in one pipeline, see core and SPL program 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 Stake Program transactions from the public RPC and prints every decoded DelegateStake instruction. Add the dependencies:
cargo add carbon-core@2.0.0 carbon-stake-program-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_stake_program_decoder::{
instructions::StakeProgramInstruction, StakeProgramDecoder, 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(StakeProgramDecoder, InstructionLogger)
.build()?
.run()
.await
}
struct InstructionLogger;
impl Processor<InstructionProcessorInputType<'_, StakeProgramInstruction>> for InstructionLogger {
async fn process(
&mut self,
input: &InstructionProcessorInputType<'_, StakeProgramInstruction>,
) -> CarbonResult<()> {
let signature = input.metadata.transaction_metadata.signature;
if let StakeProgramInstruction::DelegateStake { data, accounts, .. } = input.decoded_instruction {
println!("delegate_stake {signature}: {data:?} stake={}", accounts.stake);
}
Ok(())
}
}RUST_LOG=info cargo runEach DelegateStake instruction prints one line with the transaction signature and the decoded DelegateStake 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.
Instructions#
Variants of StakeProgramInstruction. Each is StakeProgramInstruction::, 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
Stake11111111111111111111111111111111111111. - 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.
Authorize#
Discriminator 01 · data Authorize · accounts AuthorizeInstructionAccounts.
| Field | Type |
|---|---|
arg0 | Pubkey |
arg1 | StakeAuthorize |
Required accounts: 3 (4 listed); extras go to remaining.
Fields of AuthorizeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | stake | Pubkey |
| 1 | clock_ | Pubkey |
| 2 | authority | Pubkey |
| 3 | lockup_ | Option< |
| 4… | remaining | Vec< |
AuthorizeChecked#
Discriminator 0a · data AuthorizeChecked · accounts AuthorizeCheckedInstructionAccounts.
| Field | Type |
|---|---|
stake_ | StakeAuthorize |
Required accounts: 4 (5 listed); extras go to remaining.
Fields of AuthorizeCheckedInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | stake | Pubkey |
| 1 | clock_ | Pubkey |
| 2 | authority | Pubkey |
| 3 | new_ | Pubkey |
| 4 | lockup_ | Option< |
| 5… | remaining | Vec< |
AuthorizeCheckedWithSeed#
Discriminator 0b · data AuthorizeCheckedWithSeed · accounts AuthorizeCheckedWithSeedInstructionAccounts.
| Field | Type |
|---|---|
arg0 | AuthorizeCheckedWithSeedParams |
Required accounts: 4 (5 listed); extras go to remaining.
Fields of AuthorizeCheckedWithSeedInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | stake | Pubkey |
| 1 | base | Pubkey |
| 2 | clock_ | Pubkey |
| 3 | new_ | Pubkey |
| 4 | lockup_ | Option< |
| 5… | remaining | Vec< |
AuthorizeWithSeed#
Discriminator 08 · data AuthorizeWithSeed · accounts AuthorizeWithSeedInstructionAccounts.
| Field | Type |
|---|---|
arg0 | AuthorizeWithSeedParams |
Required accounts: 3 (4 listed); extras go to remaining.
Fields of AuthorizeWithSeedInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | stake | Pubkey |
| 1 | base | Pubkey |
| 2 | clock_ | Pubkey |
| 3 | lockup_ | Option< |
| 4… | remaining | Vec< |
Deactivate#
Discriminator 05 · data Deactivate · accounts DeactivateInstructionAccounts.
No data fields.
Required accounts: 3; extras go to remaining.
Fields of DeactivateInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | stake | Pubkey |
| 1 | clock_ | Pubkey |
| 2 | stake_ | Pubkey |
| 3… | remaining | Vec< |
DeactivateDelinquent#
Discriminator 0e · data DeactivateDelinquent · accounts DeactivateDelinquentInstructionAccounts.
No data fields.
Required accounts: 3; extras go to remaining.
Fields of DeactivateDelinquentInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | stake | Pubkey |
| 1 | delinquent_ | Pubkey |
| 2 | reference_ | Pubkey |
| 3… | remaining | Vec< |
DelegateStake#
Discriminator 02 · data DelegateStake · accounts DelegateStakeInstructionAccounts.
No data fields.
Required accounts: 6; extras go to remaining.
Fields of DelegateStakeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | stake | Pubkey |
| 1 | vote | Pubkey |
| 2 | clock_ | Pubkey |
| 3 | stake_ | Pubkey |
| 4 | unused | Pubkey |
| 5 | stake_ | Pubkey |
| 6… | remaining | Vec< |
GetMinimumDelegation#
Discriminator 0d · data GetMinimumDelegation · accounts GetMinimumDelegationInstructionAccounts.
No data fields.
No named accounts.
Initialize#
Discriminator 00 · data Initialize · accounts InitializeInstructionAccounts.
| Field | Type |
|---|---|
arg0 | Authorized |
arg1 | Lockup |
Required accounts: 2; extras go to remaining.
Fields of InitializeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | stake | Pubkey |
| 1 | rent_sysvar | Pubkey |
| 2… | remaining | Vec< |
InitializeChecked#
Discriminator 09 · data InitializeChecked · accounts InitializeCheckedInstructionAccounts.
No data fields.
Required accounts: 4; extras go to remaining.
Fields of InitializeCheckedInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | stake | Pubkey |
| 1 | rent_sysvar | Pubkey |
| 2 | stake_ | Pubkey |
| 3 | withdraw_ | Pubkey |
| 4… | remaining | Vec< |
Merge#
Discriminator 07 · data Merge · accounts MergeInstructionAccounts.
No data fields.
Required accounts: 5; extras go to remaining.
Fields of MergeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | destination_ | Pubkey |
| 1 | source_ | Pubkey |
| 2 | clock_ | Pubkey |
| 3 | stake_ | Pubkey |
| 4 | stake_ | Pubkey |
| 5… | remaining | Vec< |
MoveLamports#
Discriminator 11 · data MoveLamports · accounts MoveLamportsInstructionAccounts.
| Field | Type |
|---|---|
args | u64 |
Required accounts: 3; extras go to remaining.
Fields of MoveLamportsInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | source_ | Pubkey |
| 1 | destination_ | Pubkey |
| 2 | stake_ | Pubkey |
| 3… | remaining | Vec< |
MoveStake#
Discriminator 10 · data MoveStake · accounts MoveStakeInstructionAccounts.
| Field | Type |
|---|---|
args | u64 |
Required accounts: 3; extras go to remaining.
Fields of MoveStakeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | source_ | Pubkey |
| 1 | destination_ | Pubkey |
| 2 | stake_ | Pubkey |
| 3… | remaining | Vec< |
Redelegate#
Discriminator 0f · data Redelegate · accounts RedelegateInstructionAccounts.
No data fields.
No named accounts.
SetLockup#
Discriminator 06 · data SetLockup · accounts SetLockupInstructionAccounts.
| Field | Type |
|---|---|
arg0 | LockupParams |
Required accounts: 2; extras go to remaining.
Fields of SetLockupInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | stake | Pubkey |
| 1 | authority | Pubkey |
| 2… | remaining | Vec< |
SetLockupChecked#
Discriminator 0c · data SetLockupChecked · accounts SetLockupCheckedInstructionAccounts.
| Field | Type |
|---|---|
arg0 | LockupCheckedParams |
Required accounts: 2 (3 listed); extras go to remaining.
Fields of SetLockupCheckedInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | stake | Pubkey |
| 1 | authority | Pubkey |
| 2 | new_ | Option< |
| 3… | remaining | Vec< |
Split#
Discriminator 03 · data Split · accounts SplitInstructionAccounts.
| Field | Type |
|---|---|
args | u64 |
Required accounts: 3; extras go to remaining.
Fields of SplitInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | stake | Pubkey |
| 1 | split_stake | Pubkey |
| 2 | stake_ | Pubkey |
| 3… | remaining | Vec< |
Withdraw#
Discriminator 04 · data Withdraw · accounts WithdrawInstructionAccounts.
| Field | Type |
|---|---|
args | u64 |
Required accounts: 5 (6 listed); extras go to remaining.
Fields of WithdrawInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | stake | Pubkey |
| 1 | recipient | Pubkey |
| 2 | clock_ | Pubkey |
| 3 | stake_ | Pubkey |
| 4 | withdraw_ | Pubkey |
| 5 | lockup_ | Option< |
| 6… | remaining | Vec< |
Types#
Types used by the instructions, accounts and events above, exported from carbon_.
AuthorizeCheckedWithSeedParams#
Struct types::.
| Field | Type |
|---|---|
stake_ | StakeAuthorize |
authority_ | String |
authority_ | Pubkey |
Authorized#
Struct types::.
| Field | Type |
|---|---|
staker | Pubkey |
withdrawer | Pubkey |
AuthorizeWithSeedParams#
Struct types::.
| Field | Type |
|---|---|
new_ | Pubkey |
stake_ | StakeAuthorize |
authority_ | String |
authority_ | Pubkey |
Delegation#
Struct types::.
| Field | Type |
|---|---|
voter_ | Pubkey |
stake | u64 |
activation_ | Epoch |
deactivation_ | Epoch |
warmup_ | f64 |
Epoch#
Alias types:: = u64.
Lockup#
Struct types::.
| Field | Type |
|---|---|
unix_ | UnixTimestamp |
epoch | Epoch |
custodian | Pubkey |
LockupCheckedParams#
Struct types::.
| Field | Type |
|---|---|
unix_ | Option< |
epoch | Option< |
LockupParams#
Struct types::.
| Field | Type |
|---|---|
unix_ | Option< |
epoch | Option< |
custodian | Option< |
Meta#
Struct types::Meta.
| Field | Type |
|---|---|
rent_ | u64 |
authorized | Authorized |
lockup | Lockup |
Stake#
Struct types::.
| Field | Type |
|---|---|
delegation | Delegation |
credits_ | u64 |
StakeAuthorize#
Enum types::.
| Variant |
|---|
Staker |
Withdrawer |
StakeFlags#
Struct types::.
| Field | Type |
|---|---|
bits | u8 |
StakeState#
Enum types::.
StakeStateV2#
Enum types::.
| Variant | Fields |
|---|---|
Uninitialized | |
Initialized | Meta |
Stake | Meta, Stake, StakeFlags |
RewardsPool |
UnixTimestamp#
Alias types:: = i64.