Module: Solace::Composers

Defined in:
lib/solace/composers/base.rb,
lib/solace/composers/system_program_transfer_composer.rb,
lib/solace/composers/spl_token_program_mint_to_composer.rb,
lib/solace/composers/spl_token_program_transfer_composer.rb,
lib/solace/composers/system_program_create_account_composer.rb,
lib/solace/composers/spl_token_program_close_account_composer.rb,
lib/solace/composers/spl_token_program_initialize_mint_composer.rb,
lib/solace/composers/spl_token_program_transfer_checked_composer.rb,
lib/solace/composers/associated_token_account_program_create_account_composer.rb,
lib/solace/composers/associated_token_account_program_create_idempotent_account_composer.rb

Overview

The Composers module contains classes responsible for building and ordering the accounts and instructions required for common Solana operations.

Composers abstract away the complexity of account ordering, permission management, and instruction data construction. They provide a high-level interface for creating instructions that interact with on-chain programs. Each composer corresponds to a specific program instruction (e.g., transferring SOL, minting tokens, creating accounts).

Composers handle:

  • Account resolution and ordering

  • Permission flags (signer, writable)

  • Account deduplication

  • Instruction data formatting

Examples:

Using a composer

# Initialize a transaction composer
composer = TransactionComposer.new(connection: connection)

# Create a transfer instruction composer
ix = Solace::Composers::SystemProgramTransferComposer.new(
  from: sender.public_key,
  to: recipient.public_key,
  lamports: 1_000_000
)

# Add the instruction to the transaction composer and compose the transaction
tx = composer
  .add_instruction(ix)
  .set_fee_payer(sender.public_key)
  .compose_transaction

See Also:

Since:

  • 0.0.3

Defined Under Namespace

Classes: AssociatedTokenAccountProgramCreateAccountComposer, AssociatedTokenAccountProgramCreateIdempotentAccountComposer, Base, SplTokenProgramCloseAccountComposer, SplTokenProgramInitializeMintComposer, SplTokenProgramMintToComposer, SplTokenProgramTransferCheckedComposer, SplTokenProgramTransferComposer, SystemProgramCreateAccountComposer, SystemProgramTransferComposer