Get Validator by Index
validator.getByIndex
Gets a validator address by index.
Usage
import { } from './viem.config'
const = await ..({
: 0n,
})
.('Validator:', )
Validator: 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbbimport { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Recipes
Sample a Random Validator for a Health Probe
Combine validator.getCount with getByIndex to pick a random validator, then load its record with validator.get to probe its endpoint.
import { } from './viem.config'
const = await ..()
const = (.(.() * ()))
const = await ..({ })
const { } = await ..({ : })
.('Probing:', )
Probing: validator.example.com:9000import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Return Value
type ReturnType = AddressValidator address at the index.
Parameters
index
- Type:
bigint
Validator index.
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.