const url = ("xxx") // change with your alchemi url
const provider = new ethers.providers.JsonRpcProvider(url);
const response = await provider.getBlockNumber()
import { ethers } from "ethers";
import React, { useState, useEffect } from 'react'
const App = () => {
const [block, setBlock] = useState("")
const getBlock = async () => {
const url = ("xxx") // change with your alchemi url
const provider = new ethers.providers.JsonRpcProvider(url);
try {
const response = await provider.getBlockNumber()
setBlock(response)
} catch (error) {
console.log(error, 'ini error block')
}
}
useEffect(() => {
getBlock()
return () => {
setBlock("")
}
}, [])
return (
<Box>
{block}
</Box>
)
}
export default AppBarTop