Docs

GetBuyWithCryptoQuote

Get a quote containing a TransactionRequest for swapping any token pair.

Usage

using Thirdweb.Pay;
public async void GetQuote()
{
string connectedAddress = await ThirdwebManager.Instance.SDK.Wallet.GetAddress();
BuyWithCryptoQuoteParams swapQuoteParams = new BuyWithCryptoQuoteParams(
fromAddress: connectedAddress,
fromChainId: 137,
fromTokenAddress: Utils.NativeTokenAddress; // MATIC
toTokenAddress: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270"; // WMATIC
toAmount: "2" // I want to buy 2 WMATIC
);
BuyWithCryptoQuoteResult quote = await ThirdwebPay.GetBuyWithCryptoQuote(swapQuoteParams);
ThirdwebDebug.Log($"Quote: {JsonConvert.SerializeObject(_quote, Formatting.Indented)}");
}