Documentation Index
Fetch the complete documentation index at: https://www.dynamic.xyz/docs/llms.txt
Use this file to discover all available pages before exploring further.
getCheckoutTransactionQuote
Fetches a conversion quote for a checkout transaction. The quote includes fee breakdowns and the signing payload needed for on-chain execution.
Call attachCheckoutTransactionSource before requesting a quote to specify the source wallet and chain.
Usage
import { getCheckoutTransactionQuote } from '@dynamic-labs-sdk/client';
const transaction = await getCheckoutTransactionQuote({
transactionId: 'txn_abc123',
fromTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // USDC
});
console.log('Total fee:', transaction.quote.fees?.totalFeeUsd);
Parameters
| Parameter | Type | Description |
|---|
transactionId | string | The checkout transaction ID returned by createCheckoutTransaction. |
fromTokenAddress | string | The contract address of the token the user is paying with. |
fromChainId | string (optional) | Overrides the source chain ID recorded by attachCheckoutTransactionSource for this quote. The chain family (fromChainName) and source address (fromAddress) remain locked to the attached source — to switch chain families or wallets, call attachCheckoutTransactionSource again. |
slippage | number (optional) | Maximum allowed slippage as a decimal (e.g., 0.005 for 0.5%). |
Returns
Promise<CheckoutTransaction> - The updated transaction with quote data populated:
type CheckoutTransactionQuote = {
estimatedTimeSec: number; // Estimated execution time
fees?: CheckoutFeeBreakdown; // Fee details
signingPayload: object; // Data for on-chain signing
// ... additional quote fields
};
type CheckoutFeeBreakdown = {
totalFeeUsd?: string; // Total fees in USD
// ... individual fee components
};
Examples
Display quote to user
import {
attachCheckoutTransactionSource,
getCheckoutTransactionQuote,
getActiveNetworkData,
} from '@dynamic-labs-sdk/client';
const getQuote = async (transactionId, walletAccount, tokenAddress) => {
const { networkData } = await getActiveNetworkData({ walletAccount });
// Attach source wallet
await attachCheckoutTransactionSource({
transactionId,
fromAddress: walletAccount.address,
fromChainId: networkData?.networkId ?? '',
fromChainName: walletAccount.chain,
});
// Fetch quote
const transaction = await getCheckoutTransactionQuote({
transactionId,
fromTokenAddress: tokenAddress,
});
const { quote } = transaction;
console.log(`Amount: $${transaction.amount}`);
console.log(`Fees: $${quote.fees?.totalFeeUsd ?? '0.00'}`);
return transaction;
};
With custom slippage
import { getCheckoutTransactionQuote } from '@dynamic-labs-sdk/client';
const transaction = await getCheckoutTransactionQuote({
transactionId: 'txn_abc123',
fromTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
slippage: 0.01, // 1% slippage tolerance
});
Quote against a different source chain on the same chain family
The attached source locks the chain family (e.g. EVM) and the source address, but you can request quotes against any chain in that family by passing fromChainId. This avoids re-calling attachCheckoutTransactionSource just to switch between, for example, Ethereum mainnet and Base.
import { getCheckoutTransactionQuote } from '@dynamic-labs-sdk/client';
// Source previously attached on Ethereum mainnet (chain id '1').
// Re-quote the same transaction as if paying from Base (chain id '8453').
const transaction = await getCheckoutTransactionQuote({
transactionId: 'txn_abc123',
fromTokenAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
fromChainId: '8453',
});