Send Transaction from Instructions with Wallet App
Sends a transaction using a wallet app (like Phantom, Solflare, etc.) instead of a local keypair. This is the recommended way to send transactions in browser environments.
Returns: Promise<string>
(transaction signature)
const signature = await connection.sendTransactionFromInstructionsWithWalletApp({
feePayer: walletApp, // TransactionSendingSigner from your wallet app
instructions: [instruction1, instruction2],
abortSignal: null, // Optional: AbortSignal for cancellation
});
Options
feePayer
:TransactionSendingSigner
- The wallet app signer to use for paying fees and signinginstructions
:Array<IInstruction>
- Array of instructions to include in the transactionabortSignal
:AbortSignal | null
- Optional signal to abort the transaction
Examples
Send a transaction using a wallet app:
const signature = await connection.sendTransactionFromInstructionsWithWalletApp({
feePayer: walletApp,
instructions: [instruction1, instruction2],
});
Send a transaction with the ability to cancel:
const controller = new AbortController();
const signature = await connection.sendTransactionFromInstructionsWithWalletApp({
feePayer: walletApp,
instructions: [instruction1, instruction2],
abortSignal: controller.signal,
});
// To cancel the transaction:
controller.abort();
See also: Sign Message from Wallet App
Last updated on