Skip to content

CanisterStatus

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

You can request a canisters Controllers, ModuleHash, Candid interface, Subnet, or Time, or provide a custom path CanisterStatus.CustomPath and pass arbitrary buffers for valid paths identified in https://internetcomputer.org/docs/current/references/ic-interface-spec.

The primary method for this namespace is CanisterStatus.request

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

A read_state path defined by the user, with a string DecodeStrategy. Consumed by the status utilities (e.g. CanisterStatus.request), which translate it into a KnownPath before calling Agent.readState.

the key to use to access the returned value in the status map

the path to the desired value

the strategy used to decode the returned value

Use KnownPath with Agent.readState instead.

new CustomPath(key, path, decodeStrategy): CustomPath

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

string

string | Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike>[]

DecodeStrategy

CustomPath

decodeStrategy: DecodeStrategy

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

key: string

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

path: string | Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike>[]

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

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

agent: HttpAgent

Defined in: packages/core/src/agent/canisterStatus/index.ts:83

The agent to use to make the canister request. Must be authenticated.

canisterId: Principal

Defined in: packages/core/src/agent/canisterStatus/index.ts:79

The effective canister ID to use in the underlying HttpAgent.readState call.

optional disableCertificateTimeVerification?: boolean

Defined in: packages/core/src/agent/canisterStatus/index.ts:93

Whether to disable the certificate freshness checks.

false

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

Defined in: packages/core/src/agent/canisterStatus/index.ts:88

The paths to request.

[]

DecodeStrategy = "cbor" | "hex" | "leb128" | "utf-8" | "raw"

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

Decode strategy for a CustomPath. 'raw' returns the looked-up bytes unchanged.


Path = "time" | "controllers" | "subnet" | "module_hash" | "candid" | CustomPath

Defined in: packages/core/src/agent/canisterStatus/index.ts:35

Pre-configured fields for canister status paths


Status = BaseStatus | SubnetStatus

Defined in: packages/core/src/agent/canisterStatus/index.ts:30


StatusMap = Map<Path | string, Status>

Defined in: packages/core/src/agent/canisterStatus/index.ts:37


SubnetStatus = BaseSubnetStatus

Defined in: packages/core/src/agent/canisterStatus/index.ts:29

fetchNodeKeys(certificate, canisterId, root_key?): BaseSubnetStatus

Defined in: packages/core/src/agent/canisterStatus/index.ts:183

Lookup node keys from a certificate for a given canister. The certificate is assumed to be already verified, including whether the canister is in range of the subnet.

Uint8Array

the certificate to lookup node keys from

Principal

the canister ID to lookup node keys for

Uint8Array<ArrayBufferLike>

the root key to use to lookup node keys

BaseSubnetStatus

a map of node IDs to public keys


request(options): Promise<StatusMap>

Defined in: packages/core/src/agent/canisterStatus/index.ts:115

Requests information from a canister’s read_state endpoint. Can be used to request information about the canister’s controllers, time, module hash, candid interface, and more.

[!WARNING] Requesting the subnet path from the canister status might be deprecated in the future. Use SubnetStatus.request to fetch subnet information instead.

CanisterStatusOptions

The configuration for the canister 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.

Use HttpAgent.readState directly with StatePaths instead. This function will be removed in a future release.

CanisterStatusOptions for detailed options.

const status = await canisterStatus({
paths: ['controllers', 'candid'],
...options
});
const controllers = status.get('controllers');