Class: Solace::Programs::Token2022

Inherits:
Base
  • Object
show all
Includes:
TokenProgramInterface
Defined in:
lib/solace/programs/token_2022.rb

Overview

Client for interacting with the Token-2022 Program (formerly Token Extensions).

Token-2022 is the successor to the legacy SPL Token program (TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb). Its base instructions —Transfer, TransferChecked, CloseAccount, MintTo, InitializeMint — are wire-compatible with the legacy program; only the program account they target is different. The shared method shape comes from TokenProgramInterface; this class supplies the Token-2022-bound composer classes. Branching between SPL Token and Token-2022 belongs at the call site, where the developer already knows which mint they hold.

Important: mints owned by Token-2022 (e.g. PYUSD on Solana) derive their Associated Token Accounts with this program ID in the seed. When working with such a mint, pass token_program_id: Solace::Constants::TOKEN_2022_PROGRAM_ID to AssociatedTokenAccount.get_address. Use Connection#get_mint_program_id to discover which token program owns a given mint at runtime.

This class does not yet expose the Token-2022 extension instructions (transfer hooks, transfer fees, confidential transfer, etc.); those are out of scope for the base instruction surface.

Examples:

Create a Token-2022 mint

program = Solace::Programs::Token2022.new(connection: connection)

tx = program.create_mint(
  payer: payer,
  funder: funder,
  decimals: 6,
  mint_account: ,
  mint_authority: mint_authority
)

See Also:

Since:

  • 0.1.5

Instance Attribute Summary

Attributes inherited from Base

#connection, #program_id

Instance Method Summary collapse

Methods included from TokenProgramInterface

#compose_create_mint, #compose_mint_to, #compose_transfer, #compose_transfer_checked, #create_mint, #mint_to, #transfer, #transfer_checked

Constructor Details

#initialize(connection:) ⇒ Token2022

Initializes a new Token-2022 client.

Parameters:

Since:

  • 0.1.5



47
48
49
# File 'lib/solace/programs/token_2022.rb', line 47

def initialize(connection:)
  super(connection: connection, program_id: Solace::Constants::TOKEN_2022_PROGRAM_ID)
end