Skip to main content
Access real-time token pricing information for supported tokens across all chains.
The DZap SDK provides token pricing capabilities, enabling you to get current price information for tokens when retrieving token details.

Get Token Prices

Get current prices for multiple tokens:
import { DZapClient } from "@dzapio/sdk";

const dZap = DZapClient.getInstance();

// Get current prices for multiple tokens
const prices = await dZap.getTokenPrices(
  [
    "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
    "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
  ],
  1 // Ethereum mainnet
);

console.log("Current Prices:");
Object.entries(prices).forEach(([address, price]) => {
  console.log(`Token ${address}: $${price || "N/A"}`);
});

Get Specific Token Details with Price

Get detailed information for a specific token including current price:
// Get detailed information for a specific token with price
const tokenDetails = await dZap.getTokenDetails(
  "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC address
  1, // Ethereum mainnet
  userAccount, // account (optional)
  false, // includeBalance
  true // includePrice
);

console.log("Token Details with Price:", tokenDetails);
console.log("Current Price:", tokenDetails.price);

Multi-Token Price Comparison

Fetch prices for several tokens and display them side by side:
const tokens = [
  { address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", label: "WETH" },
  { address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", label: "WBTC" },
  { address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", label: "USDC" },
  { address: "0x6B175474E89094C44Da98b954EedeAC495271d0F", label: "DAI" },
];

const prices = await dZap.getTokenPrices(
  tokens.map((t) => t.address),
  1 // Ethereum mainnet
);

console.log("Token Price Comparison:");
console.log("Symbol  | Price (USD)");
console.log("--------|------------");
tokens.forEach((t) => {
  const price = prices[t.address];
  console.log(`${t.label.padEnd(8)}| $${price ?? "N/A"}`);
});

Token Information with Pricing

When price information is requested, each token includes pricing data:
type TokenInfoWithPrice = {
  contract: string; // Contract address
  symbol: string; // Token symbol (e.g., "USDC")
  decimals: number; // Number of decimals
  name: string; // Full name (e.g., "USD Coin")
  balance: string; // User's balance (if account provided)
  price?: string; // Current price in USD
  chainId: number; // Chain ID where token exists
  balanceInUsd?: number | null; // USD value of user's balance
  isDisabledOnSwapBridge?: {
    source: boolean; // Disabled as source token
    destination: boolean; // Disabled as destination token
  };
  isDisabledOnZap?: {
    source: boolean; // Disabled for zap operations
    destination: boolean;
  };
};

Next Steps