Skip to content

Create a Transaction

Stores a set of inner instructions on-chain as a pending vault transaction — it does not execute yet. This is step one of the async lifecycle: the transaction awaits a proposal and approvals before it can run.

The creator must hold the Initiate permission. The transaction is stored at the settings account's transaction_index + 1; the program derives that index and the Transaction PDA for you. Scope: simple messages only — no Address Lookup Tables or ephemeral signers.

Program method — create_transaction

Signs with payer + creator + rent_payer, then sends.

ParameterTypeRequiredDefaultDescription
payerKeypairyesPays the fee; co-signs.
settings#to_syesThe settings account address.
creator#to_s · KeypairyesAn Initiate-holding member; must sign.
rent_payer#to_s · KeypairyesFunds the Transaction account's rent; must sign.
instructionsArray<Composers::Base>yesInner instruction composers (e.g. a SystemProgramTransferComposer spending from the vault).
account_indexIntegerno0Vault index the inner message spends from.
memoStringnonilOptional indexing memo.

Plus the shared sign: / execute: controls and Solace::Transaction return — see Conventions.

ruby
recipient = Solace::Keypair.generate

program.create_transaction(
  payer:        creator,
  settings:     identity.settings_address,
  creator:,
  rent_payer:   creator,
  instructions: [
    Solace::Composers::SystemProgramTransferComposer.new(
      from:     identity.smart_account_address,
      to:       recipient.address,
      lamports: 250_000_000
    )
  ]
)

Composer — SquadsSmartAccountsCreateTransactionComposer

The composer compiles the inner instructions into the stored message itself. The Transaction PDA must be resolved first (the program method derives it from the next index).

ParameterTypeRequiredDefaultDescription
settings#to_syesThe settings account address.
transaction#to_syesThe Transaction PDA to create (from get_transaction_address).
creator#to_s · KeypairyesAn Initiate-holding member; must sign.
rent_payer#to_s · KeypairyesFunds the account's rent; must sign.
instructionsArray<Composers::Base>yesInner instruction composers.
account_indexIntegerno0Vault index the message spends from.
ephemeral_signersIntegerno0Ephemeral signer count (only 0 is supported).
memoStringnonilIndexing memo.
ruby
transaction, = program.get_transaction_address(
  settings_address:  identity.settings_address,
  transaction_index: 1
)

composer = Solace::Composers::SquadsSmartAccountsCreateTransactionComposer.new(
  settings:     identity.settings_address,
  transaction:,
  creator:      creator.address,
  rent_payer:   creator.address,
  instructions: [
    Solace::Composers::SystemProgramTransferComposer.new(
      from:     identity.smart_account_address,
      to:       recipient.address,
      lamports: 250_000_000
    )
  ]
)

tx = Solace::TransactionComposer.new(connection:)
                                .add_instruction(composer)
                                .set_fee_payer(creator)
                                .compose_transaction

tx.sign(creator)
connection.send_transaction(tx.serialize)

Low-level instruction (advanced)

The deployed program models the args as a TransactionPayload enum and requires a trailing program account — both reflected here.

  • Discriminator: [227, 193, 53, 239, 55, 126, 112, 105]
  • Encodes (data): [0] (TransactionPayload variant) + account_index + ephemeral_signers + bytes(transaction_message) + option_string(memo)
ParameterTypeRequiredDefaultDescription
account_indexIntegeryesVault index the message spends from.
ephemeral_signersIntegeryesEphemeral signer count (0).
transaction_messageArray<Integer>yesThe serialized compiled message bytes.
memoString, nilyesIndexing memo, or nil.
settings_indexIntegeryesIndex of the settings account.
transaction_indexIntegeryesIndex of the Transaction PDA.
creator_indexIntegeryesIndex of the creator.
rent_payer_indexIntegeryesIndex of the rent payer.
system_program_indexIntegeryesIndex of the System program.
program_indexIntegeryesIndex of the Squads program.

Built on Solace