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

Returns

TransactionPlanExecutor

Example

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

See

TransactionPlannerConfig

On this page