Class: Solace::Instructions::Token2022::TransferCheckedInstruction
- Inherits:
-
Object
- Object
- Solace::Instructions::Token2022::TransferCheckedInstruction
- Defined in:
- lib/solace/instructions/token_2022/transfer_checked_instruction.rb
Overview
Instruction for transferring Token-2022 tokens with decimal validation.
Constant Summary collapse
- INSTRUCTION_INDEX =
Token-2022 instruction index for Transfer Checked
[12].freeze
Class Method Summary collapse
-
.build(amount:, decimals:, to_index:, from_index:, mint_index:, authority_index:, program_index: 3) ⇒ Solace::Instruction
Builds a Solace::Instruction for transferring Token-2022 tokens.
-
.data(amount, decimals) ⇒ Array
Instruction data for a TransferChecked instruction.
Class Method Details
.build(amount:, decimals:, to_index:, from_index:, mint_index:, authority_index:, program_index: 3) ⇒ Solace::Instruction
Builds a Solace::Instruction for transferring Token-2022 tokens.
The BufferLayout is:
- [Instruction Index (1 byte)]
- [Amount (8 bytes little-endian u64)]
- [Decimals (1 byte)]
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/solace/instructions/token_2022/transfer_checked_instruction.rb', line 39 def self.build( amount:, decimals:, to_index:, from_index:, mint_index:, authority_index:, program_index: 3 ) Solace::Instruction.new.tap do |ix| ix.program_index = program_index ix.accounts = [from_index, mint_index, to_index, ] ix.data = data(amount, decimals) end end |
.data(amount, decimals) ⇒ Array
Instruction data for a TransferChecked instruction.
60 61 62 63 64 |
# File 'lib/solace/instructions/token_2022/transfer_checked_instruction.rb', line 60 def self.data(amount, decimals) INSTRUCTION_INDEX + Solace::Utils::Codecs.encode_le_u64(amount).bytes + [decimals] end |