Get Validator Count
validator.getCount
Gets the total number of validators.
Usage
import { } from './viem.config'
const = await ..()
.('Result:', )
Result: 4nimport { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Recipes
Derive Quorum Figures for a Health Dashboard
Use the validator count to derive standard BFT fault-tolerance figures for a network health dashboard.
import { } from './viem.config'
const = await ..()
const = ( - 1n) / 3n
const = -
.(`Quorum: ${} of ${} validators`)
Quorum: 3 of 4 validatorsimport { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Return Value
type ReturnType = bigintThe total number of validators.
Parameters
blockNumber (optional)
- Type:
bigint
Block number to read the state from.
blockOverrides (optional)
- Type:
BlockOverrides
Block overrides to apply to the state.
blockTag (optional)
- Type:
BlockTag
Block tag to read the state from.
stateOverride (optional)
- Type:
StateOverride
State override to apply.