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

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

Overview

A class to build the InitializeAccount instruction for the SPL Token Program.

Constant Summary collapse

INSTRUCTION_INDEX =
[1].freeze

Class Method Summary collapse

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:



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/solace/instructions/spl_token/initialize_account_instruction.rb', line 20

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



40
41
42
# File 'lib/solace/instructions/spl_token/initialize_account_instruction.rb', line 40

def self.data
  INSTRUCTION_INDEX
end