failedSingleTransactionPlanResult

function failedSingleTransactionPlanResult<
    TContext,
    TTransactionMessage,
>(
    transactionMessage,
    error,
): SingleTransactionPlanResult<TContext, TTransactionMessage>;

Creates a failed SingleTransactionPlanResult from a transaction message and error.

This function creates a single result with a 'failed' status, indicating that the transaction execution failed. It includes the original transaction message and the error that caused the failure.

Type Parameters

Type ParameterDefault typeDescription
TContext extends TransactionPlanResultContextTransactionPlanResultContextThe type of the context object (not used in failed results)
TTransactionMessage extends Readonly<{ instructions: readonly Instruction<string, readonly (/api/functions/ | AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]; version: TransactionVersion; }> & TransactionMessageWithFeePayer<string>Readonly<{ instructions: readonly Instruction<string, readonly (/api/functions/ | AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]; version: TransactionVersion; }> & TransactionMessageWithFeePayer<string>The type of the transaction message

Parameters

ParameterTypeDescription
transactionMessageTTransactionMessageThe original transaction message
errorSolanaErrorThe error that caused the transaction to fail

Returns

SingleTransactionPlanResult<TContext, TTransactionMessage>

Example

const result = failedSingleTransactionPlanResult(
  transactionMessage,
  new SolanaError({
    code: 123,
    message: 'Transaction simulation failed',
  }),
);
result satisfies SingleTransactionPlanResult;

See

SingleTransactionPlanResult

On this page