usePlanTransaction

function usePlanTransaction(
    client,
): ActionResult<
    [InstructionPlanInput],
    TransactionMessage & TransactionMessageWithFeePayer<string>
>;

Plans a single transaction from an instruction input, as a reactive action.

Wraps client.planTransaction 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 you expect all instructions to fit in a single transaction; reach for usePlanTransactions when they might need splitting.

Parameters

ParameterTypeDescription
clientClientWithTransactionPlanningA client with a transaction-planning plugin installed.

Returns

ActionResult<[InstructionPlanInput], TransactionMessage & TransactionMessageWithFeePayer<string>>

An ActionResult whose dispatch/dispatchAsync take the InstructionPlanInput and resolve with the planned transaction message.

Example

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

See

On this page