GetBuyWithCryptoQuote
Get a quote containing a TransactionRequest for swapping any token pair.
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; // MATICtoTokenAddress: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270"; // WMATICtoAmount: "2" // I want to buy 2 WMATIC);BuyWithCryptoQuoteResult quote = await ThirdwebManager.Instance.SDK.Pay.GetBuyWithCryptoQuote(swapQuoteParams);ThirdwebDebug.Log($"Quote: {JsonConvert.SerializeObject(quote, Formatting.Indented)}");}
A BuyWithCryptoQuoteParams
object (with a helpful constructor) containing the following properties:
string fromAddress; // Address executing the swapBigInteger? fromChainId; // Chain ID of the from tokenstring fromTokenAddress; // Address of the from tokenstring toTokenAddress; // Address of the to tokenstring fromAmount; // Optional, amount of from tokenstring fromAmountWei; // Optional, amount of from token in weiBigInteger? toChainId; // Optional, chain ID of the to tokenstring toAmount; // Optional, amount of to tokenstring toAmountWei; // Optional, amount of to token in weiint? maxSlippageBPS; // Optional, maximum slippage in basis pointsstring intentId; // Optional, intent identifier used to link status to a BuyWithFiat onramp flow if any
A BuyWithCryptoQuoteResult
object containing the following properties:
string quoteId; // Quote identifierTransactionRequest transactionRequest; // TransactionRequest object for the swapApproval approval; // Approval transaction details if neededstring fromAddress; // Address executing the swapToken fromToken; // Token object of the from tokenToken toToken; // Token object of the to tokenstring fromAmountWei; // Amount of from token in weistring fromAmount; // Amount of from tokenstring toAmountMinWei; // Minimum amount of to token in weistring toAmountMin; // Minimum amount of to tokenstring toAmountWei; // Amount of to token in weistring toAmount; // Amount of to tokenList<PaymentToken> paymentTokens; // Payment token detailsList<ProcessingFee> processingFees; // Processing fee detailsEstimated estimated; // Estimated usd values, slippage, duration if availableint maxSlippageBPS; // Maximum slippage in basis pointsstring bridge // Bridge to be used if applicable