createTransactionPlanExecutor

function createTransactionPlanExecutor(config): TransactionPlanExecutor;

Creates a new transaction plan executor based on the provided configuration.

The executor will traverse the provided TransactionPlan sequentially or in parallel, executing each transaction message using the executeTransactionMessage function.

  • If that function is successful, the executor will return a successful TransactionPlanResult for that message including the transaction and any custom context.
  • If that function throws an error, the executor will stop processing and cancel all remaining transaction messages in the plan.
  • If the abortSignal is triggered, the executor will immediately stop processing the plan and return a TransactionPlanResult with the status set to canceled.

Parameters

ParameterTypeDescription
configTransactionPlanExecutorConfigConfiguration object containing the transaction message executor function.

Returns

TransactionPlanExecutor

A TransactionPlanExecutor function that can execute transaction plans.

Throws

SOLANA_ERROR__INSTRUCTION_PLANS__FAILED_TO_EXECUTE_TRANSACTION_PLAN if any transaction in the plan fails to execute. The error context contains a transactionPlanResult property with the partial results up to the point of failure.

Throws

SOLANA_ERROR__INSTRUCTION_PLANS__NON_DIVISIBLE_TRANSACTION_PLANS_NOT_SUPPORTED if the transaction plan contains non-divisible sequential plans, which are not supported by this executor.

Example

const sendAndConfirmTransaction = sendAndConfirmTransactionFactory({ rpc, rpcSubscriptions });
 
const transactionPlanExecutor = createTransactionPlanExecutor({
  executeTransactionMessage: async (message) => {
    const transaction = await signTransactionMessageWithSigners(message);
    await sendAndConfirmTransaction(transaction, { commitment: 'confirmed' });
    return { transaction };
  }
});

See

TransactionPlanExecutorConfig

On this page