Docs

getBuyWithCryptoQuote

Get a quote of type BuyWithCryptoQuote to buy any given token with crypto. This quote contains the information about the swap such as token amounts, processing fees, estimated time etc.

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

Example

import { getBuyWithCryptoQuote } from "@thirdweb-dev/sdk";
const quote = await getBuyWithCryptoQuote({
clientId: "...",
fromAddress: "0x...", // wallet address
fromChainId: 137, // chain id of the source token
fromTokenAddress: "0x...", // token address of the source token
fromAmount: "10", // amount of source token to swap
// optionally, you can use `toAmount` instead if you only want a certain amount of destination token
toChainId: 10, // chain id of the destination token
toTokenAddress: "0x...", // token address of the destination token
toAddress: "0x...", // optional: send the tokens to a different address
maxSlippageBPS: 50, // optional: max 0.5% slippage
});

Parameters

Returns

Object of type BuyWithCryptoQuote which contains the information about the quote such as processing fees, estimated time, converted token amounts, etc.