createFailedToSendTransactionError

function createFailedToSendTransactionError(
    result,
    abortReason?,
): SolanaError<11>;

Creates a SolanaError with the SOLANA_ERROR__FAILED_TO_SEND_TRANSACTION error code from a failed or canceled SingleTransactionPlanResult.

This is a high-level error designed for user-facing transaction send failures. It unwraps simulation errors (such as preflight failures) to expose the underlying transaction error as the cause, and extracts preflight data and logs into the error context for easy access.

The error message includes an indicator showing whether the failure was a preflight error or includes the on-chain transaction signature for easy copy-pasting into block explorers.

Parameters

ParameterTypeDescription
result| CanceledSingleTransactionPlanResult | FailedSingleTransactionPlanResultA failed or canceled single transaction plan result.
abortReason?unknownAn optional abort reason if the transaction was canceled.

Returns

SolanaError<11>

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

Example

Creating an error from a failed transaction plan result.

import { createFailedToSendTransactionError } from '@solana/instruction-plans';
 
const error = createFailedToSendTransactionError(failedResult);
console.log(error.message);
// "Failed to send transaction (preflight): Insufficient funds for fee"
console.log(error.cause);
// The unwrapped transaction error
console.log(error.context.logs);
// Transaction logs from the preflight simulation

See

createFailedToSendTransactionsError

On this page