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

**URL:** <https://forum.dfinity.org/t/invalid-certificate-canister-aaaaa-aa-not-in-range-of-delegations-for-subnet/23244>\
**Category:** Developers\
**Created:** [September 22, 2023, 9:52pm UTC](https://forum.dfinity.org/t/invalid-certificate-canister-aaaaa-aa-not-in-range-of-delegations-for-subnet/23244 "2023-09-22T21:52:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![infu](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/infu/32/11321_2.png) [@infu](https://forum.dfinity.org/u/infu)\
**Post date:** [September 22, 2023, 9:52pm UTC](https://forum.dfinity.org/t/invalid-certificate-canister-aaaaa-aa-not-in-range-of-delegations-for-subnet/23244/1 "2023-09-22T21:52:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [September 22, 2023, 11:02pm UTC](https://forum.dfinity.org/t/invalid-certificate-canister-aaaaa-aa-not-in-range-of-delegations-for-subnet/23244/2 "2023-09-22T23:02:17Z")

</div>

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.

> <https://github.com/dfinity/agent-js/blob/main/e2e/node/canisters/counter.ts#L25>

---

<div class="post-metadata">

**Author:** ![levi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/levi/32/22608_2.png) [@levi](https://forum.dfinity.org/u/levi)\
**Post date:** [September 22, 2023, 11:03pm UTC](https://forum.dfinity.org/t/invalid-certificate-canister-aaaaa-aa-not-in-range-of-delegations-for-subnet/23244/3 "2023-09-22T23:03:19Z")

</div>

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](https://agent-js.icp.xyz/agent/interfaces/CallOptions.html#effectiveCanisterId) as the canister that is being installed.
