Class: Solace::Instructions::Token2022::TransferInstruction
- Inherits:
-
Object
- Object
- Solace::Instructions::Token2022::TransferInstruction
- Defined in:
- lib/solace/instructions/token_2022/transfer_instruction.rb
Overview
Instruction for transferring tokens via the Token-2022 program.
Constant Summary collapse
- INSTRUCTION_INDEX =
[3].freeze
Instance Attribute Summary collapse
-
#INSTRUCTION_INDEX ⇒ Object
readonly
Instruction index for Token-2022’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 Token-2022’s Transfer instruction.
33 |
# File 'lib/solace/instructions/token_2022/transfer_instruction.rb', line 33 INSTRUCTION_INDEX = [3].freeze |
Class Method Details
.build(amount:, owner_index:, source_index:, destination_index:, program_index:) ⇒ Solace::Instruction
Builds a Transfer instruction.
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/solace/instructions/token_2022/transfer_instruction.rb', line 43 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)]
65 66 67 |
# File 'lib/solace/instructions/token_2022/transfer_instruction.rb', line 65 def self.data(amount) INSTRUCTION_INDEX + Solace::Utils::Codecs.encode_le_u64(amount).bytes end |