Network
Network =
"ic"|"local"|"env"| {host:string;rootKey?:Uint8Array;name?:string;fetchRootKey?:boolean; }
Defined in: core/src/network.ts:64
Where the canisters are.
"ic": mainnet, throughhttps://icp-api.io, checked against the mainnet root key the agent ships with. Nothing is fetched."local": a replica onhttp://127.0.0.1:4943. Its root key is fetched from the replica before the first call."env": the network of the page this code runs in, as an asset canister or a dev server describes it. In a browser, a page on a local replica or on a mainnet boundary domain (and a Codespaces or Gitpod page, which forwards a local dev server) routes through its own origin. The root key comes from theic_envcookie, but only where that cookie is trusted: when both the page and the replica are local, or the client was built withallowEnvConfig: true. A local replica with no key from the cookie has its root key fetched. A Codespaces or Gitpod page is routed but is not local, so there the key is neither taken from the cookie nor fetched, and the agent checks the forwarded replica’s certificates against mainnet’s key, so every certified call fails verification. SetallowEnvConfig: trueto take the cookie’s key, or name the replica with an object that has arootKeyorfetchRootKey: true. On a server there is no page and no cookie: the host isICP_HOSTorIC_HOSTwhenICP_NETWORKorDFX_NETWORKis"local"(http://127.0.0.1:4943if neither is set), and mainnet otherwise.- An object: any other replica.
rootKeyis used as given and never fetched. Without one the root key is fetched only whenhostis local (localhost,*.localhostor any loopback address), unlessfetchRootKeysays otherwise. A replica behind a Codespaces, Gitpod or custom domain is not local: pass itsrootKey, or writefetchRootKey: trueto trust the key it reports.nameis the network’s segment in query keys and defaults tohost.
Union Members
Section titled “Union Members”"ic"
"local"
"env"
Type Literal
Section titled “Type Literal”{ host: string; rootKey?: Uint8Array; name?: string; fetchRootKey?: boolean; }
readonlyhost:string
The replica’s URL. A host with no scheme is read against the page’s protocol, as HttpAgent reads it.
rootKey?
Section titled “rootKey?”
readonlyoptionalrootKey?:Uint8Array
The root key certificates are verified against. Used as given and
never fetched, even where fetchRootKey is true.
readonlyoptionalname?:string
This network’s segment in query keys. Defaults to host.
fetchRootKey?
Section titled “fetchRootKey?”
readonlyoptionalfetchRootKey?:boolean
Whether to fetch the root key from the replica when rootKey is
absent. Defaults to whether host is local. Writing true for a host
that is not local trusts whatever key that host reports, which is why it
is never the default.