createFailedToSignTransactionError

function createFailedToSignTransactionError<TContext>(
    result,
    abortReason?,
): SolanaError<13>;

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

This is the signing counterpart to createFailedToSendTransactionError, designed for user-facing failures raised by executors that sign a transaction without submitting it. It behaves identically — unwrapping simulation errors to expose the underlying transaction error as the cause, and extracting preflight data and logs into the error context — because signing executors typically estimate resource limits by simulating before they sign.

Unlike the sending variant, the message carries no indicator of where the failure happened. That indicator locates a failure relative to network submission — (preflight) before it, or the transaction signature after it — and signing never submits, so neither applies. The logs and preflightData context properties are still populated whenever a simulation was responsible, and those logs still appear in the message, so nothing is lost beyond the prefix.

Type Parameters

Type ParameterDefault typeDescription
TContext extends TransactionPlanResultContextTransactionPlanResultContextThe type of the context object attached to the result. Any context is accepted, since this helper never reads from it.

Parameters

ParameterTypeDescription
result| CanceledSingleTransactionPlanResult<TContext> | FailedSingleTransactionPlanResult<TContext>A failed or canceled single transaction plan result.
abortReason?unknownAn optional abort reason if the transaction was canceled.

Returns

SolanaError<13>

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

Example

Creating an error from a failed transaction plan result.

import { createFailedToSignTransactionError } from '@solana/instruction-plans';
 
const error = createFailedToSignTransactionError(failedResult);
console.log(error.message);
// "Failed to sign transaction: The user rejected the signing request"
console.log(error.cause);
// The unwrapped signing error

See

On this page