Query the Validator Set
Get info on validators for an L1.
Query the Validator Set
Before getting into understanding and executing validator manager operations, let's take a look at our current Validator set.
Feel free to come back to this step after adding a validator, changing weight or removing it to verify the changes have applied.
Builder Console
L1 Validators
Query the validators of an L1 from the P-Chain using the Avalanche API
Subnet ID is required to query L1 validators
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { AvaCloudSDK } from "@avalabs/avacloud-sdk";
const sdk = new AvaCloudSDK({
serverURL: "https://api.avax.network",
network: "mainnet",
});
const result = await sdk.data.primaryNetwork.listL1Validators({
network: "mainnet",
subnetId: "<your-subnet-id>",
});
// Paginate through all results
const allValidators = [];
for await (const page of result) {
if ("result" in page && page.result) {
allValidators.push(...page.result.validators);
}
}
console.log(`Found ${allValidators.length} validators`);
allValidators.forEach((v) => {
console.log(` ${v.nodeId} - weight: ${v.weight}`);
});Uses the AvaCloud Data API to list L1 validators
Is this guide helpful?


