createTransactionPlanner

function createTransactionPlanner(config): TransactionPlanner;

Creates a new transaction planner based on the provided configuration.

At the very least, the createTransactionMessage function must be provided. This function is used to create new transaction messages whenever needed.

Additionally, the onTransactionMessageUpdated function can be provided to update transaction messages during the planning process. This function will be called whenever a transaction message is updated, e.g. when new instructions are added to a transaction message. It accepts the updated transaction message and must return a transaction message back, even if no changes were made.

You may also provide maxInstructionsPerTransaction to limit the number of instructions in each planned transaction message. This limit includes any instructions already present in messages returned by createTransactionMessage and any instructions added by onTransactionMessageUpdated. It must be a positive integer no greater than the hard limit of 64 instructions per transaction; larger values throw. Defaults to 16.

Parameters

ParameterType
configTransactionPlannerConfig

Returns

TransactionPlanner

Example

const transactionPlanner = createTransactionPlanner({
  createTransactionMessage: () => pipe(
    createTransactionMessage({ version: 0 }),
    message => setTransactionMessageFeePayerSigner(mySigner, message),
  )
});

See

TransactionPlannerConfig

On this page