usePlanTransactions

function usePlanTransactions(
    client,
): ActionResult<[InstructionPlanInput], TransactionPlan>;

Plans one or more transactions from an instruction input, as a reactive action.

Wraps client.planTransactions with useAction: each dispatch(input) runs the plan with a fresh AbortSignal and tracks its lifecycle through React state. Calling dispatch again while a previous plan is in flight aborts the first. Use this when the instructions might be split across multiple transactions due to size limits; reach for usePlanTransaction for the single- transaction case.

Parameters

ParameterTypeDescription
clientClientWithTransactionPlanningA client with a transaction-planning plugin installed.

Returns

ActionResult<[InstructionPlanInput], TransactionPlan>

An ActionResult whose dispatch/dispatchAsync take the InstructionPlanInput and resolve with the full TransactionPlan.

Example

const { dispatch, data, isRunning } = usePlanTransactions(client);
<button disabled={isRunning} onClick={() => dispatch(instructions)}>Plan</button>

See

On this page