UNPKG

@molecularlabs/nucleus-frontend

Version:
22 lines 593 B
import { CHAINLINK_ADDRESS } from "../constants"; import { ChainlinkAbi } from "../contracts/chainlink-abi"; import { getClient } from "../lib/client"; async function getEthPrice({ chainId }) { const client = await getClient(chainId); const priceData = await client.readContract({ abi: ChainlinkAbi, address: CHAINLINK_ADDRESS, functionName: "latestRoundData", args: [] }); if (!priceData || !priceData[1]) { throw new Error("Failed to fetch ETH price from Chainlink"); } return priceData[1]; } export { getEthPrice }; //# sourceMappingURL=chainlink.mjs.map