@@ -49,6 +49,7 @@ export default function Home() {
4949 ( ) => new JsonRpcProvider ( process . env . NEXT_PUBLIC_DEFAULT_RPC_URL )
5050 ) ;
5151 const [ chainId , setChainId ] = useState ( BigInt ( 0 ) ) ;
52+ const [ currentBlock , setCurrentBlock ] = useState < number > ( 0 ) ;
5253 const [ rpcUrl , setRpcUrl ] = useState ( process . env . NEXT_PUBLIC_DEFAULT_RPC_URL ) ;
5354 const [ wallet , setWallet ] = useState < HDNodeWallet | null > ( null ) ;
5455 const [ nonce , setNonce ] = useState ( 0 ) ;
@@ -149,6 +150,22 @@ export default function Home() {
149150 return ( ) => clearInterval ( interval ) ;
150151 } , [ provider ] ) ;
151152
153+ // Add this effect for block number updates
154+ useEffect ( ( ) => {
155+ const updateBlockNumber = async ( ) => {
156+ try {
157+ const blockNumber = await provider . getBlockNumber ( ) ;
158+ setCurrentBlock ( blockNumber ) ;
159+ } catch ( error ) {
160+ console . error ( "Failed to fetch block number:" , error ) ;
161+ }
162+ } ;
163+
164+ updateBlockNumber ( ) ;
165+ const interval = setInterval ( updateBlockNumber , 1500 ) ;
166+ return ( ) => clearInterval ( interval ) ;
167+ } , [ provider ] ) ;
168+
152169 // Handler: airdrop funds and set up wallet
153170 const handleAirdrop = async ( ) => {
154171 const w = Wallet . createRandom ( ) . connect ( provider ) ;
@@ -338,11 +355,17 @@ export default function Home() {
338355 { pingLatency } ms
339356 </ p >
340357 </ div >
341- < div className = "col-span-3" >
358+ < div className = "space-y-1" >
359+ < p className = "text-sm text-gray-400" > Current Block</ p >
360+ < p className = "text-2xl font-mono text-[#00FFB2]" >
361+ { currentBlock }
362+ </ p >
363+ </ div >
364+ < div className = "col-span-2" >
342365 < p className = "text-sm text-gray-400 mb-2" >
343366 Confirmation Latencies
344367 </ p >
345- < div className = "grid grid-cols-3 gap-4" >
368+ < div className = "grid grid-cols-2 gap-4" >
346369 < div className = "space-y-1" >
347370 < p className = "text-sm text-gray-400" > Median</ p >
348371 < p className = "text-2xl font-mono text-[#00FFB2]" >
0 commit comments