'use client'; import React, { useState } from 'react'; import { ethers } from 'ethers'; import { getContract } from '@/lib/ethers'; const FlareFeed = () => { const [feedValue, setFeedValue] = useState(null); const [decimals, setDecimals] = useState(null); const [timestamp, setTimestamp] = useState(null); const handleGetFeed = async () => { try { const contract = getContract(); const feedData = await contract.getFlareFeed(); const _feedValue = ethers.utils.formatEther(feedData[0].toString()); const _decimals = feedData[1]; const _timestamp = new Date(feedData[2] * 1000).toLocaleString(); setFeedValue(_feedValue); setDecimals(_decimals); setTimestamp(_timestamp); } catch (error) { console.error('Error fetching Flare feed data:', error); } }; return (

Flare Token Feed

{feedValue && (

Feed Value (FLR/USD): {feedValue}

Decimals: {decimals}

Timestamp: {timestamp}

)}
); }; export default FlareFeed;