Hook to get a quote of type BuyWithCryptoQuote for buying tokens with crypto. This quote contains the information about the purchase such as token amounts, processing fees, estimated time etc.

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

Once you have the quote, you can use the useBuyWithCryptoStatus function to get the status of the swap transaction.


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.hash 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 BuyWithCryptoQuote