useSendTransaction

function useSendTransaction(client): ActionResult<
    [
        | InstructionPlanInput
        | (TransactionMessage & TransactionMessageWithFeePayer<string>)
        | Readonly<{
              kind: 'single';
              message: TransactionMessage &
                  TransactionMessageWithFeePayer<string>;
              planType: 'transactionPlan';
          }>,
    ],
    SuccessfulSingleTransactionPlanResult
>;

Sends a single transaction to the network, as a reactive action.

Wraps client.sendTransaction with useAction, which handles signing, submission, and confirmation. Each dispatch(input) runs with a fresh AbortSignal and tracks its lifecycle through React state; calling dispatch again while a previous send is in flight aborts the first. Accepts flexible input: instructions, an instruction plan, a single transaction message, or a single transaction plan. Use useSendTransactions when the work may span multiple transactions.

Parameters

ParameterTypeDescription
clientClientWithTransactionSendingA client with a transaction-sending plugin installed.

Returns

ActionResult<[ | InstructionPlanInput | TransactionMessage & TransactionMessageWithFeePayer<string> | Readonly<{ kind: "single"; message: TransactionMessage & TransactionMessageWithFeePayer<string>; planType: "transactionPlan"; }>], SuccessfulSingleTransactionPlanResult>

An ActionResult whose dispatch/dispatchAsync take the input and resolve with the SuccessfulSingleTransactionPlanResult.

Example

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

See

On this page