Class: Solace::Composers::SplTokenProgramMintToComposer
- Defined in:
- lib/solace/composers/spl_token_program_mint_to_composer.rb
Overview
Composer for creating a MintTo instruction for the SPL Token Program.
This composer builds a MintTo instruction that can be added to a transaction to mint tokens to a specified token account. It is used to mint new tokens for a given mint and destination account.
Required accounts:
- **Mint**: The mint account (writable, non-signer)
- **Destination**: The token account to mint to (writable, non-signer)
- **Mint Authority**: The mint authority account (readonly, signer)
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#amount ⇒ Integer
Extracts the amount from the params.
-
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices.
-
#destination ⇒ String
Extracts the destination address from the params.
-
#mint ⇒ String
Extracts the mint address from the params.
-
#mint_authority ⇒ String
Extracts the mint authority address from the params.
-
#setup_accounts ⇒ void
Setup accounts required for MintTo instruction Called automatically during initialization.
-
#spl_token_program ⇒ String
Returns the spl token program id.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Solace::Composers::Base
Instance Method Details
#amount ⇒ Integer
Extracts the amount from the params
56 57 58 |
# File 'lib/solace/composers/spl_token_program_mint_to_composer.rb', line 56 def amount params[:amount].to_i end |
#build_instruction(account_context) ⇒ Solace::Instruction
Build instruction with resolved account indices
75 76 77 78 79 80 81 82 83 |
# File 'lib/solace/composers/spl_token_program_mint_to_composer.rb', line 75 def build_instruction(account_context) Instructions::SplToken::MintToInstruction.build( amount: amount, mint_index: account_context.index_of(mint), destination_index: account_context.index_of(destination), mint_authority_index: account_context.index_of(), program_index: account_context.index_of(spl_token_program) ) end |
#destination ⇒ String
Extracts the destination address from the params
35 36 37 |
# File 'lib/solace/composers/spl_token_program_mint_to_composer.rb', line 35 def destination params[:destination].to_s end |
#mint ⇒ String
Extracts the mint address from the params
28 29 30 |
# File 'lib/solace/composers/spl_token_program_mint_to_composer.rb', line 28 def mint params[:mint].to_s end |
#mint_authority ⇒ String
Extracts the mint authority address from the params
42 43 44 |
# File 'lib/solace/composers/spl_token_program_mint_to_composer.rb', line 42 def params[:mint_authority].to_s end |
#setup_accounts ⇒ void
This method returns an undefined value.
Setup accounts required for MintTo instruction Called automatically during initialization
64 65 66 67 68 69 |
# File 'lib/solace/composers/spl_token_program_mint_to_composer.rb', line 64 def setup_accounts account_context.add_writable_nonsigner(mint) account_context.add_writable_nonsigner(destination) account_context.add_readonly_signer() account_context.add_readonly_nonsigner(spl_token_program) end |
#spl_token_program ⇒ String
Returns the spl token program id
49 50 51 |
# File 'lib/solace/composers/spl_token_program_mint_to_composer.rb', line 49 def spl_token_program Constants::TOKEN_PROGRAM_ID.to_s end |