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:67

Interface to define a custom path. Nested paths will be represented as individual buffers, and can be created from text using TextEncoder.

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

the path to the desired value, represented as an array of buffers

the strategy to use to decode the returned value

new CustomPath(key, path, decodeStrategy): CustomPath

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

string

string | Uint8Array<ArrayBufferLike>[]

DecodeStrategy

CustomPath

decodeStrategy: DecodeStrategy

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

CustomPath.decodeStrategy

key: string

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

CustomPath.key

path: string | Uint8Array<ArrayBufferLike>[]

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

CustomPath.path

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

agent: HttpAgent

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

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

canisterId: Principal

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

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

optional disableCertificateTimeVerification?: boolean

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

Whether to disable the certificate freshness checks.

false

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

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

The paths to request.

[]

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

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

Decode strategy for custom paths


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

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

Pre-configured fields for canister status paths


Status = BaseStatus | SubnetStatus

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


StatusMap = Map<Path | string, Status>

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


SubnetStatus = BaseSubnetStatus

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

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

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

Path

Principal

Uint8Array<ArrayBufferLike>[]


fetchNodeKeys(certificate, canisterId, root_key?): BaseSubnetStatus

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

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:81

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.

CanisterStatusOptions for detailed options.

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