getBuyWithCryptoTransfer

Get a quote of type BuyWithCryptoTransfer to facilitate a token transfer transaction. Using this instead of a native transfer allows you to receive status and webhooks about successful or failed payments.

Once you have the quote, you can use prepareTransaction and prepare the transaction for submission.

Example

import { getBuyWithCryptoTransfer } from "thirdweb/pay";
const transfer = await getBuyWithCryptoTransfer({
client,
fromAddress: "0x...", // wallet address
toAddress: "0x...", // recipient address - likely to be your wallet
chainId: 10, // chain id of the token
tokenAddress: "0x...", // address of the token
amount: "10", // amount of token to transfer
purchaseData: {
// any metadata for you to attribute this purchase
customerId: "yourId",
},
});
function getBuyWithCryptoTransfer(

Parameters

object of type GetBuyWithCryptoTransferParams

Type

let params: {
amount: string;
chainId: number;
client: ThirdwebClient;
fromAddress: string;
purchaseData?: object;
toAddress: string;
tokenAddress: string;
};

Returns

let returnType: {
client: ThirdwebClient;
estimatedGasCostUSDCents: number;
fromAddress: string;
paymentToken: QuotePaymentToken;
processingFee: QuotePaymentToken;
toAddress: string;
transactionRequest: PrepareTransactionOptions;
};

Object of type BuyWithCryptoTransfer which contains the information about the transfer