Class: Solace::Instructions::AssociatedTokenAccount::CreateAssociatedTokenAccountInstruction
- Inherits:
-
Object
- Object
- Solace::Instructions::AssociatedTokenAccount::CreateAssociatedTokenAccountInstruction
- Defined in:
- lib/solace/instructions/associated_token_account/create_associated_token_account_instruction.rb
Overview
Instruction for creating an Associated Token Account.
This is a special “all-in-one” instruction that creates and initializes the account. It is used to create an Associated Token Account (ATA) for a given mint and owner.
Constant Summary collapse
- INSTRUCTION_INDEX =
!@const INSTRUCTION_INDEX
Instruction index for CreateAssociatedTokenAccount [0].freeze
Class Method Summary collapse
-
.build(funder_index:, associated_token_account_index:, owner_index:, mint_index:, system_program_index:, token_program_index:, program_index:) ⇒ Solace::Instruction
Builds a CreateAssociatedTokenAccount instruction.
-
.data ⇒ Array
Data for a CreateAssociatedTokenAccount instruction.
Class Method Details
.build(funder_index:, associated_token_account_index:, owner_index:, mint_index:, system_program_index:, token_program_index:, program_index:) ⇒ Solace::Instruction
Builds a CreateAssociatedTokenAccount instruction.
The on-chain program requires accounts in a specific order:
- writable, signer
-
Funder: The account paying for the rent.
- writable
-
ATA: The new Associated Token Account to be created.
- readonly
-
Owner: The wallet that will own the new ATA.
- readonly
-
Mint: The token mint for the new ATA.
- readonly
-
System Program: Required to create the account.
- readonly
-
SPL Token Program: Required to initialize the account.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/solace/instructions/associated_token_account/create_associated_token_account_instruction.rb', line 48 def self.build( funder_index:, associated_token_account_index:, owner_index:, mint_index:, system_program_index:, token_program_index:, program_index: ) Solace::Instruction.new.tap do |ix| ix.program_index = program_index ix.accounts = [ funder_index, associated_token_account_index, owner_index, mint_index, system_program_index, token_program_index ] ix.data = data end end |
.data ⇒ Array
Data for a CreateAssociatedTokenAccount instruction
The BufferLayout is:
- [Instruction Index (1 byte)]
77 78 79 |
# File 'lib/solace/instructions/associated_token_account/create_associated_token_account_instruction.rb', line 77 def self.data INSTRUCTION_INDEX end |