import { useTokenPrice } from "@relayprotocol/relay-kit-hooks";
import { useRelayClient } from "@relayprotocol/relay-kit-ui";
import { zeroAddress } from "viem";
const {
data: ethPriceResponse,
isLoading,
error,
} = useTokenPrice(
{
address: zeroAddress, // Native currency (ETH)
chainId: 8453, // Base chain ID
},
{
// Optional query options
refetchInterval: 60000, // Refresh every minute
}
);
if (isLoading) {
console.log("Loading ETH price...");
} else if (error) {
console.error("Error fetching ETH price:", error);
} else {
console.log("ETH Price on Base:", ethPriceResponse?.price); // Access the price from the data object
}