Invalid certificate: Canister aaaaa-aa not in range of delegations for subnet

I am trying to create a js script using agent-js that creates a new wallet canister the same way dfx does it.
The script successfully creates the canister with CMC using notify_create_canister, but while trying to call the management canister install_code returns an error.

Invalid certificate: Canister aaaaa-aa not in range of delegations for subnet 0xba488d13a5dd7649d8093fe4897df1cc7c728ab64c856a78c4b97d6a02

We do this in our e2e tests, although the management canister interface hasn’t been updated a while and we’re not running our CI on mainnet.

1 Like

On calls to the management canister, the effective_canister_id must be set in the call as the canister-target of the call, so for install_code that is the canister that is being installed.

In agent-js set this parameter: https://agent-js.icp.xyz/agent/interfaces/CallOptions.html#effectiveCanisterId as the canister that is being installed.

1 Like