Assessment reports>BPF Stake Program>Threat Model>Instruction: Initialize

Instruction: Initialize

This instruction initializes an uninitialized stake account with authorization and lockup information.

Input structure

pub struct Authorized { pub staker: Pubkey, pub withdrawer: Pubkey, } pub struct Lockup { /// UnixTimestamp at which this stake will allow withdrawal, unless the /// transaction is signed by the custodian pub unix_timestamp: UnixTimestamp, /// epoch height at which this stake will allow withdrawal, unless the /// transaction is signed by the custodian pub epoch: Epoch, /// custodian signature on a transaction exempts the operation from /// lockup constraints pub custodian: Pubkey, } pub enum StakeInstruction { /// # Account references /// 0. `[WRITE]` Uninitialized stake account /// 1. `[]` Rent sysvar Initialize(Authorized, Lockup) } fn process_initialize( accounts: &[AccountInfo], authorized: Authorized, lockup: Lockup, ) -> ProgramResult {

Parameters

  • authorized: The staker and withdrawer to be authorized.

  • lockup: The lockup information.

Lockup

  • unix_timestamp: Unix timestamp when the lockup expires.

  • epoch: Epoch when the lockup expires.

  • custodian: Custodian key on a transaction exempts the operation from lockup constraints.

  • authorized: The staker and withdrawer to be authorized.

  • lockup: The lockup information.

Accounts

  • stake_account: The uninitialized stake account.

    • Signer: No.

    • Init: No.

    • PDA: No.

    • Writable: Yes.

    • Rent checks: The account must be rent-exempt.

    • Ownership checks: The account must be owned by the program.

    • Address checks: None.

  • rent: The account must be a rent sysvar.

Additional checks and behavior

  • The size of the stake account must be equal to the size of StakeStateV2.

  • The stake account must be uninitialized.

  • The stake account must have enough lamports to be rent-exempt.

  • The stake account is initialized with the provided authorized and lockup information.

Zellic © 2025Back to top ↑