Deploying (the icp ledger canister) to production

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:

// ...
"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:

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)

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!

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?

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) ?

// 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:

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 !

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.

Looks like a bug that I ran into recently as well. This 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

1 Like

Thanks to you both :pray:

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

1 Like