Class: Solace::Instructions::Token2022::InitializeAccountInstruction

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

Overview

Instruction for initializing a new Token-2022 token account.

Used in conjunction with the SystemProgram::CreateAccount instruction to create and initialize a new token account. For the common case of an associated token account, prefer AssociatedTokenAccount::CreateAccountInstruction.

Examples:

Build an InitializeAccount instruction

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

Since:

  • 0.1.5

Constant Summary collapse

INSTRUCTION_INDEX =

Since:

  • 0.1.5

[1].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#INSTRUCTION_INDEXObject (readonly)

Instruction index for Token-2022’s InitializeAccount instruction.



26
# File 'lib/solace/instructions/token_2022/initialize_account_instruction.rb', line 26

INSTRUCTION_INDEX = [1].freeze

Class Method Details

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

Builds a Token2022::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 Token-2022 program in the transaction’s accounts.

Returns:

Since:

  • 0.1.5



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/solace/instructions/token_2022/initialize_account_instruction.rb', line 36

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 Token2022::InitializeAccount instruction.

The BufferLayout is:

- [Instruction Index (1 byte)]

Returns:

  • (Array)

    1-byte instruction index

Since:

  • 0.1.5



56
57
58
# File 'lib/solace/instructions/token_2022/initialize_account_instruction.rb', line 56

def self.data
  INSTRUCTION_INDEX
end