Expand description
Queries active validators on the network.
Returns details and the state of validation on the blockchain.
§Examples
-
Get the validators for a specified epoch.
use near_jsonrpc_client::{methods, JsonRpcClient}; use near_primitives::types::{EpochReference, EpochId, BlockReference, Finality}; let client = JsonRpcClient::connect("https://archival-rpc.testnet.fastnear.com"); let request = methods::validators::RpcValidatorRequest { epoch_reference: EpochReference::EpochId( "ECjBFyob3eKjDnDWDrbX4pkiSbGRAGyiHbS4ZVY8dxvD".parse()?, ) }; let response = client.call(request).await?; assert!(matches!( response, methods::validators::RpcValidatorResponse { .. } )); -
Get the validators for the latest block.
use near_jsonrpc_client::{methods, JsonRpcClient}; use near_primitives::types::{EpochReference, EpochId, BlockId}; let client = JsonRpcClient::connect("https://archival-rpc.testnet.fastnear.com"); let request = methods::validators::RpcValidatorRequest { epoch_reference: EpochReference::Latest }; let response = client.call(request).await?; assert!(matches!( response, methods::validators::RpcValidatorResponse { .. } ));