Class: Solace::Instructions::SplToken::InitializeAccountInstruction

Inherits:
Object
  • Object
show all
Defined in:
lib/solace/instructions/spl_token/initialize_account_instruction.rb

Overview

Instruction for initializing a new token account.

This instruction is used to initialize a new token account for a given mint and owner. It is used in conjunction with the CreateAccount instruction to create and initialize a new token account. Note that the AssociatedTokenAccount::CreateAssociatedTokenAccountInstruction is a special “all-in-one” instruction that creates and initializes the account in a single instruction.

Examples:

Build an InitializeAccount instruction

instruction = Solace::Instructions::SplToken::InitializeAccountInstruction.build(
  account_index: 0,
  mint_index: 1,
  owner_index: 2,
  rent_sysvar_index: 3,
  program_index: 4
)

See Also:

Since:

  • 0.0.2

Constant Summary collapse

INSTRUCTION_INDEX =

Since:

  • 0.0.2

[1].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#INSTRUCTION_INDEXObject (readonly)

Instruction index for SPL Token Program’s InitializeAccount instruction.



31
# File 'lib/solace/instructions/spl_token/initialize_account_instruction.rb', line 31

INSTRUCTION_INDEX = [1].freeze

Class Method Details

.build(account_index:, mint_index:, owner_index:, rent_sysvar_index:, program_index:) ⇒ Solace::Instruction

Builds a SPLToken::InitializeAccount instruction.

Parameters:

  • account_index (Integer)

    Index of the new token account in the transaction’s accounts.

  • mint_index (Integer)

    Index of the mint account in the transaction’s accounts.

  • owner_index (Integer)

    Index of the owner of the new account in the transaction’s accounts.

  • rent_sysvar_index (Integer)

    Index of the Rent Sysvar in the transaction’s accounts.

  • program_index (Integer)

    Index of the SPL Token program in the transaction’s accounts.

Returns:

Since:

  • 0.0.2



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/solace/instructions/spl_token/initialize_account_instruction.rb', line 41

def self.build(
  account_index:,
  mint_index:,
  owner_index:,
  rent_sysvar_index:,
  program_index:
)
  Solace::Instruction.new.tap do |ix|
    ix.program_index = program_index
    ix.accounts = [, mint_index, owner_index, rent_sysvar_index]
    ix.data = data
  end
end

.dataArray

Builds the data for a SPLToken::InitializeAccount instruction.

The BufferLayout is:

- [Instruction Index (1 byte)]

Returns:

  • (Array)

    1-byte instruction index

Since:

  • 0.0.2



61
62
63
# File 'lib/solace/instructions/spl_token/initialize_account_instruction.rb', line 61

def self.data
  INSTRUCTION_INDEX
end