From 4b2f1ce2ac1baddb4b675420dd4a45cd0670e570 Mon Sep 17 00:00:00 2001 From: Marco Walz Date: Thu, 5 Mar 2026 10:24:17 +0100 Subject: [PATCH] docs: update Motoko env var example to use motoko-core Runtime.envVar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit motoko-core v2.1.0 now provides `Runtime.envVar` as the official API for reading canister environment variables, replacing the internal `Prim.envVar` from `mo:⛔`. Co-Authored-By: Claude Opus 4.6 --- docs/concepts/canister-discovery.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/concepts/canister-discovery.md b/docs/concepts/canister-discovery.md index 4f12dc28d..d481f2ef1 100644 --- a/docs/concepts/canister-discovery.md +++ b/docs/concepts/canister-discovery.md @@ -104,20 +104,18 @@ let backend_id = Principal::from_text( ).unwrap(); ``` -**Motoko** canisters can read canister environment variables using `Prim.envVar` (since Motoko 0.16.2): +**Motoko** canisters can read canister environment variables using `Runtime.envVar` from the [motoko-core](https://mops.one/core) package (v2.1.0+): ```motoko -import Prim "mo:⛔"; +import Runtime "mo:core/Runtime"; import Principal "mo:core/Principal"; -let ?backendIdText = Prim.envVar("PUBLIC_CANISTER_ID:backend") else { +let ?backendIdText = Runtime.envVar("PUBLIC_CANISTER_ID:backend") else { return #err("backend canister ID not set"); }; let backendId = Principal.fromText(backendIdText); ``` -> **Note:** `Prim` is an internal module not intended for general use. This functionality will be available in the Motoko core package in a future release. - ### Making Inter-Canister Calls Once you have the target canister ID, make calls using your language's CDK: