Skip to content

SubnetStatus

The SubnetStatus utility is used to request structured data directly from the IC public API. This data can be accessed using agent.readSubnetState, but SubnetStatus provides a helpful abstraction with some known paths.

The primary method for this namespace is SubnetStatus.request

Defined in: packages/core/src/agent/subnetStatus/index.ts:56

agent: HttpAgent

Defined in: packages/core/src/agent/subnetStatus/index.ts:65

The agent to use to make the subnet request.

optional disableCertificateTimeVerification?: boolean

Defined in: packages/core/src/agent/subnetStatus/index.ts:75

Whether to disable the certificate freshness checks.

false

optional paths?: Set<Path> | Path[]

Defined in: packages/core/src/agent/subnetStatus/index.ts:70

The paths to request.

[]

subnetId: Principal

Defined in: packages/core/src/agent/subnetStatus/index.ts:61

The subnet ID to query. Use IC_ROOT_SUBNET_ID for the IC mainnet root subnet. You can use HttpAgent.getSubnetIdFromCanister to get a subnet ID from a canister.

Path = "time" | "canisterRanges" | "publicKey" | "nodeKeys" | CustomPath

Defined in: packages/core/src/agent/subnetStatus/index.ts:52

Pre-configured fields for subnet status paths


Status = BaseStatus | SubnetNodeKeys | CanisterRanges

Defined in: packages/core/src/agent/subnetStatus/index.ts:47


StatusMap = Map<Path | string, Status>

Defined in: packages/core/src/agent/subnetStatus/index.ts:54


SubnetStatus = BaseSubnetStatus & object

Defined in: packages/core/src/agent/subnetStatus/index.ts:40

publicKey: Uint8Array

The public key of the subnet

const IC_ROOT_SUBNET_ID: Principal

Defined in: packages/core/src/agent/utils/readState.ts:26

The root subnet ID for IC mainnet

encodePath(path, subnetId): Uint8Array<ArrayBufferLike>[]

Defined in: packages/core/src/agent/subnetStatus/index.ts:233

Encode a path for subnet state queries

Path

the path to encode

Principal

the subnet ID

Uint8Array<ArrayBufferLike>[]

the encoded path as an array of Uint8Arrays


lookupSubnetInfo(certificate, subnetId): SubnetStatus

Defined in: packages/core/src/agent/subnetStatus/index.ts:202

Fetch subnet info including node keys from a certificate

Uint8Array

the certificate bytes

Principal

the subnet ID

SubnetStatus

SubnetStatus with subnet ID and node keys


request(options): Promise<StatusMap>

Defined in: packages/core/src/agent/subnetStatus/index.ts:94

Requests information from a subnet’s read_state endpoint. Can be used to request information about the subnet’s time, canister ranges, public key, node keys, and metrics.

SubnetStatusOptions

The configuration for the subnet status request.

Promise<StatusMap>

A map populated with data from the requested paths. Each path is a key in the map, and the value is the data obtained from the certificate for that path.

SubnetStatusOptions for detailed options.

const status = await subnetStatus.request({
subnetId: IC_ROOT_SUBNET_ID,
paths: ['time', 'nodeKeys'],
agent,
});
const time = status.get('time');
const nodeKeys = status.get('nodeKeys');

Re-exports CustomPath


Re-exports DecodeStrategy