# Deploying (the icp ledger canister) to production

**URL:** <https://forum.dfinity.org/t/deploying-the-icp-ledger-canister-to-production/33133>\
**Category:** Developers\
**Created:** [July 12, 2024, 10:37pm UTC](https://forum.dfinity.org/t/deploying-the-icp-ledger-canister-to-production/33133 "2024-07-12T22:37:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![builder.icp](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/builder.icp/32/18247_2.png) [@builder.icp](https://forum.dfinity.org/u/builder.icp)\
**Post date:** [July 12, 2024, 10:37pm UTC](https://forum.dfinity.org/t/deploying-the-icp-ledger-canister-to-production/33133/1 "2024-07-12T22:37:05Z")

</div>

Hey guys,

I’m trying to deploy an app which consists of 4 canisters (that are my code) + 2 canisters that are:

- icp ledger
- internet identity

So my dfx.json file looks like this:

```auto
// ...
"icp_ledger": {
      "type": "custom",
      "candid": "https://raw.githubusercontent.com/dfinity/ic/ec35ebd252d4ffb151d2cfceba3a86c4fb87c6d6/rs/rosetta-api/icp_ledger/ledger.did",
      "wasm": "https://download.dfinity.systems/ic/ec35ebd252d4ffb151d2cfceba3a86c4fb87c6d6/canisters/ledger-canister.wasm.gz",
      "remote": {
        "id": {
          "ic": "ryjl3-tyaaa-aaaaa-aaaba-cai"
        }
      }
    },
//...

```

However when I try to deploy (`dfx deploy --network ic`), I get an error:

```auto
Error: Failed while trying to deploy canisters.

Caused by: Failed to build all canisters.

Caused by: Failed while trying to build all canisters.

Caused by: The build step failed for canister '6zf4l-iiaaa-aaaal-ajnoa-cai' (xxxx_ledger)

Caused by: Failed to build Motoko canister 'xxxx_ledger'.

Caused by: Failed to compile Motoko.

Caused by: Failed to run 'moc'.

Caused by: The command '"/Users/xxxx/.cache/dfinity/versions/0.20.1/moc" "/Users/xxxx/Code/xxxx/src/xxxx_ledger/main.mo" "-o" "/Users/xxxx/Code/xxxx/.dfx/ic/canisters/xxxx_ledger/xxxx_ledger.wasm" "-c" "--debug" "--idl" "--stable-types" "--public-metadata" "candid:service" "--public-metadata" "candid:args" "--actor-idl" "/Users/xxxx/Code/xxxx/.dfx/ic/canisters/idl/" "--actor-alias" "icp_ledger" "ryjl3-tyaaa-aaaaa-aaaba-cai" "--actor-alias" "internet_identity" "rdmx6-jaaaa-aaaaa-aaadq-cai" "--actor-alias" "xxxx_backend" "6ldls-eyaaa-aaaal-ajnna-cai" "--actor-alias" "xxxx_frontend" "6mcng-jaaaa-aaaal-ajnnq-cai" "--actor-alias" "xxxx_ledger" "6zf4l-iiaaa-aaaal-ajnoa-cai" "--actor-alias" "xxxx_timer" "66e27-fqaaa-aaaal-ajnoq-cai" "--package" "base" ".mops/base@0.11.1/src" "--package" "map" ".mops/map@9.0.1/src"' failed with exit status 'exit status: 1'.

Stdout:

Stderr:

/Users/xxxx/Code/xxxx/src/xxxx_ledger/main.mo:7.1-7.39: import error [M0009], file "/Users/xxxx/Code/xxxx/.dfx/ic/canisters/idl/ryjl3-tyaaa-aaaaa-aaaba-cai.did" does not exist

```

I remember when I first launched the icp ledger canister locally, I had to run this command:  
`dfx deploy --specified-id ryjl3-tyaaa-aaaaa-aaaba-cai icp_ledger_canister --argument..` (as per [documentation](https://internetcomputer.org/docs/current/tutorials/developer-journey/level-4/4.1-icp-ledger#deploying-the-canister))

I always thought I wouldn’t have to run such a command when I first deployed because the icp ledger canister already exists live. But now I’m running into this error, so maybe I’m wrong? (see error in green where ryjl3-tyaaa-aaaaa-aaaba-cai is the icp ledger).

Cheers!

---

<div class="post-metadata">

**Author:** ![jennifertran](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jennifertran/32/11558_2.png) [@jennifertran](https://forum.dfinity.org/u/jennifertran)\
**Post date:** [July 13, 2024, 1:51am UTC](https://forum.dfinity.org/t/deploying-the-icp-ledger-canister-to-production/33133/2 "2024-07-13T01:51:02Z")

</div>

The error is related to the canister not being able to find the declaration file listed.

Can you navigate to the file location that it is indicating and see if the file is there?

---

<div class="post-metadata">

**Author:** ![builder.icp](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/builder.icp/32/18247_2.png) [@builder.icp](https://forum.dfinity.org/u/builder.icp)\
**Post date:** [July 14, 2024, 6:58pm UTC](https://forum.dfinity.org/t/deploying-the-icp-ledger-canister-to-production/33133/3 "2024-07-14T18:58:30Z")

</div>

It’s indeed not there, but it’s a declaration file that is automatically generated when building the canister I guess, no ? Is there anything I must do besides having “icp\_ledger” declared in my dfx.json (below is a larger sample) ?

```auto
// dfx.json file
// ...
    "icp_ledger": {
      "type": "custom",
      "candid": "https://raw.githubusercontent.com/dfinity/ic/ec35ebd252d4ffb151d2cfceba3a86c4fb87c6d6/rs/rosetta-api/icp_ledger/ledger.did",
      "wasm": "https://download.dfinity.systems/ic/ec35ebd252d4ffb151d2cfceba3a86c4fb87c6d6/canisters/ledger-canister.wasm.gz",
      "remote": {
        "id": {
          "ic": "ryjl3-tyaaa-aaaaa-aaaba-cai"
        }
      }
    },
    "xxxx_ledger": {
      "main": "src/xxxx_ledger/main.mo",
      "type": "motoko",
      "dependencies": [
          "icp_ledger"
      ]
    },
// ...

```

In my xxx\_ledger canister, in main.mo, I’m indeed importing `icp_ledger` like so:

```auto
import IcpLedger "canister:icp_ledger";

```

but then what? `dfx deploy` works locally; is there anything else I must add for it to work in production ?

Thank you for your help, Jennifer !

---

<div class="post-metadata">

**Author:** ![jennifertran](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jennifertran/32/11558_2.png) [@jennifertran](https://forum.dfinity.org/u/jennifertran)\
**Post date:** [July 15, 2024, 12:58am UTC](https://forum.dfinity.org/t/deploying-the-icp-ledger-canister-to-production/33133/4 "2024-07-15T00:58:03Z")

</div>

Thank you for all of the details!

Yes, it should automatically generate as part of `dfx build` of `dfx deploy`.

You seem to importing the canister correctly as well.

Here are a few things I would suggest:

1. Delete for `.dfx` folder and then try to deploy again.
2. If that does not work, try to deploy with this command `dfx deploy —network ic —verbose` and report back. It will give more detailed logs on what’s going on.

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [July 15, 2024, 7:21am UTC](https://forum.dfinity.org/t/deploying-the-icp-ledger-canister-to-production/33133/5 "2024-07-15T07:21:20Z")

</div>

Looks like a bug that I ran into recently as well. [This](https://github.com/sesi200/fortune-wheel/blob/main/scripts/download-idl.sh) is the workaround I came up with. You need to adjust the for loop at the bottom with your canister names. If you run this before `dfx deploy --ic` it should work.

Note to self: [internal ticket](https://dfinity.atlassian.net/browse/SDKTG-357)

---

<div class="post-metadata">

**Author:** ![builder.icp](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/builder.icp/32/18247_2.png) [@builder.icp](https://forum.dfinity.org/u/builder.icp)\
**Post date:** [July 16, 2024, 9:06am UTC](https://forum.dfinity.org/t/deploying-the-icp-ledger-canister-to-production/33133/6 "2024-07-16T09:06:56Z")

</div>

Thanks to you both 🙏

Severin, your script worked: I have the missing file!  
I’m also working on a grant submission but I will soon try to finalize deployment and report back.

Cheers

---

<div class="post-metadata">

**Author:** ![fxgst](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/fxgst/32/12439_2.png) [@fxgst](https://forum.dfinity.org/u/fxgst)\
**Post date:** [January 29, 2025, 2:19pm UTC](https://forum.dfinity.org/t/deploying-the-icp-ledger-canister-to-production/33133/7 "2025-01-29T14:19:44Z")

</div>

I faced the same issue today. Here is how I worked around it: download the missing candid file manually (in my case from GitHub) and add it in the `dfx.json` under the `remote` section as a sibling to `id` of the corresponding canister:

```js
"remote": {
   "id": {
      "ic": "7hfb6-caaaa-aaaar-qadga-cai"
    },
    "candid": "path_to_did/evm_rpc.did" <---
},

```

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [January 31, 2025, 12:16pm UTC](https://forum.dfinity.org/t/deploying-the-icp-ledger-canister-to-production/33133/8 "2025-01-31T12:16:53Z")

</div>

This will be fixed with this [PR](https://github.com/dfinity/sdk/pull/4093). It will land in either dfx 0.25.0 or the following version
