useBlockTimestamp
useBlockTimestamp
hook is used to fetch current timestamp from the block.
It provides a function that basically returns the latest block's timestamp.
Usage
import { useBlockTimestamp } from "ethylene/hooks";
function App() {
const {
fetchBlockTimestamp,
} = useBlockTimestamp();
return (
<div>
<button
onClick={async () => {
const timestamp = await fetchBlockTimestamp();
console.log(`The timestamp is ${timestamp}`);
}}
>
Fetch block timestamp
</button>
</div>
);
}
API
type ReturnType = {
fetchBlockTimestamp: () => Promise<number>;
};