A hook to get a status of Buy with Crypto transaction.

This hook is a React Query wrapper of the getBuyWithCryptoStatus function. You can also use that function directly.


import { useSigner, useBuyWithCryptoQuote, useBuyWithCryptoStatus } from "@thirdweb-dev/react";
function Component() {
const buyWithCryptoQuoteQuery = useBuyWithCryptoQuote(swapParams);
const signer = useSigner();
const [buyTxHash, setBuyTxHash] = useState<string | undefined>();
const buyWithCryptoStatusQuery = useBuyWithCryptoStatus* (buyTxHash ? {
clientId: "YOUR_CLIENT_ID",
transactionHash: buyTxHash,
}: undefined);
async function handleBuyWithCrypto() {
if (! || !signer) {
// if approval is required
if ( {
const approveTx = await signer.sendTransaction(;
await approveTx.wait();
// send the transaction to buy crypto
// this promise is resolved when user confirms the transaction * in the wallet and the transaction is sent to the blockchain
const buyTx = await signer.sendTransaction(;
await buyTx.wait();
// set buyTx.transactionHash to poll the status of the swap * transaction
if ( {
console.log('', *
return <button onClick={handleBuyWithCrypto}>Swap</button>



A react query object which contains the data of type BuyWithCryptoStatus