getEpochNumber
Get the epoch number by epoch tag.
Usage
example.ts
import { publicClient } from "./client";
const epochNumber = await publicClient.getEpochNumber();Returns
bigint
Parameters
epochTag (optional)
- Type
latest_mined|latest_state|latest_confirmed|latest_checkpoint|earliest - Defaut
latest_mined
import { http, createPublicClient } from 'cive'
import { mainnet } from 'cive/chains'
export const publicClient = createPublicClient({
chain: mainnet,
transport: http(),
})
// ---cut---
const epochNumber = await publicClient.getEpochNumber({
epochTag: "latest_mined",
});cacheTime (optional)
- Type:
number - Default: Client's
cacheTime
Time (in ms) that cached block number will remain in memory. If you don't want to cache, set it to 0.
import { http, createPublicClient } from 'cive'
import { mainnet } from 'cive/chains'
export const publicClient = createPublicClient({
chain: mainnet,
transport: http(),
})
// ---cut---
const epochNumber = await publicClient.getEpochNumber({
epochTag: "latest_state",
cacheTime: 4_000,
});