Skip to contents

Fetches validator set for the current epoch (or a specific epoch) using the official validators RPC method. This is the only reliable public endpoint that returns actual stake amounts (in yoctoNEAR).

Usage

near_get_validators(epoch_id = NULL)

Arguments

epoch_id

NULL (default) for current epoch, or a specific epoch hash/ID.

Value

A tibble with one row per validator:

account_id

Validator account

public_key

Ed25519 public key

stake_yocto

Stake as big integer string

stake_near

Stake in whole NEAR (rounded to 2 decimals)

is_slashed

Logical: was validator slashed?

shards

Integer vector of assigned shards

blocks_produced / blocks_expected

Block production stats

chunks_produced / chunks_expected

Chunk production stats

uptime_pct

Overall uptime % (blocks + chunks)

epoch_height

Epoch height

raw_response

Full RPC result (for debugging)

Examples

# Current epoch validators
vals <- near_get_validators()
vals |> slice_head(n = 10)
#> Error in slice_head(vals, n = 10): could not find function "slice_head"

# Top 5 by stake
vals |> arrange(desc(stake_near)) |> slice_head(n = 5)
#> Error in slice_head(arrange(vals, desc(stake_near)), n = 5): could not find function "slice_head"

# Find any slashed validators
vals |> filter(is_slashed)
#> Error in data.matrix(data): 'list' object cannot be coerced to type 'double'

# Plot stake distribution
library(ggplot2)
vals |>
  slice_max(stake_near, n = 20) |>
  ggplot(aes(reorder(account_id, stake_near), stake_near, fill = is_slashed)) +
  geom_col() +
  coord_flip() +
  labs(title = "Top 20 NEAR Validators by Stake", x = "Validator", y = "Stake (NEAR)") +
  scale_fill_manual(values = c("FALSE" = "#00F6D2", "TRUE" = "#FF4444"))
#> Error in slice_max(vals, stake_near, n = 20): could not find function "slice_max"

# Total staked NEAR
sum(vals$stake_near)
#> [1] 591579817