Class: Solace::Instructions::SplToken::TransferInstruction
- Inherits:
-
Object
- Object
- Solace::Instructions::SplToken::TransferInstruction
- Defined in:
- lib/solace/instructions/spl_token/transfer_instruction.rb
Overview
Instruction for transferring SPL tokens.
This instruction is used to transfer SPL tokens from one token account to another.
Constant Summary collapse
- INSTRUCTION_INDEX =
[3].freeze
Instance Attribute Summary collapse
-
#INSTRUCTION_INDEX ⇒ Object
readonly
Instruction index for SPL Token Program’s Transfer instruction.
Class Method Summary collapse
-
.build(amount:, owner_index:, source_index:, destination_index:, program_index:) ⇒ Solace::Instruction
Builds a Transfer instruction.
-
.data(amount) ⇒ Array<Integer>
Builds the data for a Transfer instruction.
Instance Attribute Details
#INSTRUCTION_INDEX ⇒ Object (readonly)
Instruction index for SPL Token Program’s Transfer instruction.
23 |
# File 'lib/solace/instructions/spl_token/transfer_instruction.rb', line 23 INSTRUCTION_INDEX = [3].freeze |
Class Method Details
.build(amount:, owner_index:, source_index:, destination_index:, program_index:) ⇒ Solace::Instruction
Builds a Transfer instruction.
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/solace/instructions/spl_token/transfer_instruction.rb', line 33 def self.build( amount:, owner_index:, source_index:, destination_index:, program_index: ) Solace::Instruction.new.tap do |ix| ix.program_index = program_index ix.accounts = [source_index, destination_index, owner_index] ix.data = data(amount) end end |
.data(amount) ⇒ Array<Integer>
Builds the data for a Transfer instruction.
The BufferLayout is:
- [Instruction Index (1 byte)]
- [Amount (8 bytes)]
55 56 57 |
# File 'lib/solace/instructions/spl_token/transfer_instruction.rb', line 55 def self.data(amount) INSTRUCTION_INDEX + Solace::Utils::Codecs.encode_le_u64(amount).bytes end |