createFailedToSendTransactionsError

function createFailedToSendTransactionsError(
    result,
    abortReason?,
): SolanaError<12>;

Creates a SolanaError with the SOLANA_ERROR__FAILED_TO_SEND_TRANSACTIONS error code from a TransactionPlanResult.

This is a high-level error designed for user-facing transaction send failures involving multiple transactions. It walks the result tree, unwraps simulation errors from each failure, and builds a failedTransactions array pairing each failure with its unwrapped error, logs, and preflight data.

The error message lists each failure with its position in the plan and an indicator showing whether it was a preflight error or includes the transaction signature. When all transactions were canceled, the message is a single line.

Parameters

ParameterTypeDescription
resultTransactionPlanResultThe full transaction plan result tree.
abortReason?unknownAn optional abort reason if the plan was aborted.

Returns

SolanaError<12>

A SolanaError with the appropriate error code, context, and cause.

Example

Creating an error from a failed transaction plan result.

import { createFailedToSendTransactionsError } from '@solana/instruction-plans';
 
const error = createFailedToSendTransactionsError(planResult);
console.log(error.message);
// "Failed to send transactions.
// [Tx #1 (preflight)] Insufficient funds for fee
// [Tx #3 (5abc...)] Custom program error: 0x1"
console.log(error.context.failedTransactions);
// [{ index: 0, error: ..., logs: [...], preflightData: {...} }, ...]

See

createFailedToSendTransactionError

On this page