x402-chainlink
    Preparing search index...

    Function getLatestPrice

    • Get the latest price from a Chainlink price feed

      Parameters

      • client: {}

        Viem public client

      • feedAddress: `0x${string}`

        Price feed contract address

      Returns Promise<PriceFeedResult>

      Price feed result

      const result = await getLatestPrice(client, PRICE_FEED_ADDRESSES['eip155:8453']['ETH/USD']);
      const priceUsd = Number(result.price) / Math.pow(10, result.decimals);
      console.log(`ETH price: $${priceUsd}`);