useSendAndConfirmTransaction

A hook to send a transaction.

Example

import { useSendAndConfirmTransaction } from "thirdweb/react";
const { mutate: sendAndConfirmTx, data: transactionReceipt } =
useSendAndConfirmTransaction();
// later
sendAndConfirmTx(tx);

Gasless usage with thirdweb Engine

import { useSendAndConfirmTransaction } from "thirdweb/react";
const mutation = useSendAndConfirmTransaction({
gasless: {
provider: "engine",
relayerUrl:
"https://thirdweb.engine-***.thirdweb.com/relayer/***",
relayerForwarderAddress: "0x...",
},
});

Gasless usage with OpenZeppelin

import { useSendAndConfirmTransaction } from "thirdweb/react";
const mutation = useSendAndConfirmTransaction({
gasless: {
provider: "openzeppelin",
relayerUrl: "https://...",
relayerForwarderAddress: "0x...",
},
});
function useSendAndConfirmTransaction(
config: SendAndConfirmTransactionConfig,
): UseMutationResult<TransactionReceipt, Error, PreparedTransaction>;

Parameters

Type

let config: SendAndConfirmTransactionConfig;

Returns

let returnType: UseMutationResult<
Error,
>;

A mutation object to send a transaction.