Problems with ledger local setup

I am having problems installing the ledger locally using the instructions provided on the website. I am using the DFX_VERSION=0.14.3, and I am on a mac. I followed the instructions using a fresh install of IC.

When I get to the instructions to deploy the canister, I get the following error message:

Error: Cannot find canister id. Please issue 'dfx canister create ledger'

I then run the dfx command to create the ledger canister, and attempt to install the ledger canister again. This time around, I get the following error message:

Error: Failed to install wasm module to canister 'ledger'.
Caused by: Failed to install wasm module to canister 'ledger'.
  Failed to read /Users/hilljh/Projects/onehilltech/ic/ledger/.dfx/local/canisters/ledger/ledger.wasm.gz.
    No such file or directory (os error 2)

It seems like dfx is not downloading the wasm file. As a workaround, I manually download both the candid file and wasm file and place them in my local directory and update dfx.json accordingly. When I do that, and run the following command as listed on the website:

dfx canister install ledger --argument "(variant {Init = record { token_name = \"NAME\"; token_symbol = \"SYMB\"; transfer_fee = 1000000; metadata = vec {}; minting_account = record {owner = principal \"$(dfx --identity minter identity get-principal)\";}; initial_balances = vec {}; archive_options = record {num_blocks_to_archive = 1000000; trigger_threshold = 1000000; controller_id = principal \"$(dfx identity get-principal)\"}; }})"

I get a completely different set of errors.

Error: Failed to install wasm module to canister 'ledger'.
Caused by: Failed to install wasm module to canister 'ledger'.
  Failed during wasm installation call: The replica returned a replica error: Replica Error: reject code CanisterError, reject message Canister bkyz2-fmaaa-aaaaa-qaaaq-cai trapped explicitly: failed to decode call arguments: Custom(Fail to decode argument 0 from table0 to variant {
  Upgrade : opt record {
    token_symbol : opt text;
    transfer_fee : opt nat64;
    metadata : opt vec record {
      text;
      variant { Int : int; Nat : nat; Blob : vec nat8; Text : text };
    };
    change_fee_collector : opt variant {
      SetTo : record { owner : principal; subaccount : opt vec nat8 };
      Unset;
    };
    max_memo_length : opt nat16;
    token_name : opt text;
    feature_flags : opt record { icrc2 : bool };
  };
  Init : record {
    token_symbol : text;
    transfer_fee : nat64;
    metadata : vec record {
      text;
      variant { Int : int; Nat : nat; Blob : vec nat8; Text : text };
    };
    minting_account : record { owner : principal; subaccount : opt vec nat8 };
    initial_balances : vec record {
      record { owner : principal; subaccount : opt vec nat8 };
      nat64;
    };
    fee_collector_account : opt record {
      owner : principal;
      subaccount : opt vec nat8;
    };
    archive_options : record {
      num_blocks_to_archive : nat64;
      max_transactions_per_response : opt nat64;
      trigger_threshold : nat64;
      max_message_size_bytes : opt nat64;
      cycles_for_archive_creation : opt nat64;
      node_max_memory_size_bytes : opt nat64;
      controller_id : principal;
    };
    max_memo_length : opt nat16;
    token_name : text;
    feature_flags : opt record { icrc2 : bool };
  };
}

Caused by:
    0: input: 4449444c056b01b0ced18403016c079efeb9a40371f2c794ae037cefcee7800402aecbeb880403b2a4dab20502a1e5f7a10a0491c9aafe0d716d6f6c01b3b0dac303686c039ea581d2017ca495a5e9067cdec5d8ae0e680100_000453594d42c0843d00011d874f3ca3e65851a5177a4d36545b4677a5990406ea2618d6270ba5d60200c0843dc0843d011d4d3680e97f160e3afd56233417c2583293492eb97b646f118f9896a502044e414d45
       table: type table0 = variant { 815_032_112 : table1 }
       type table1 = record {
         881_753_886 : text;
         902_112_242 : int;
         1_075_439_471 : table2;
         1_092_281_774 : table3;
         1_448_514_098 : table2;
         2_755_523_233 : table4;
         3_754_599_569 : text;
       }
       type table2 = vec empty
       type table3 = record { 947_296_307 : principal }
       type table4 = record { 440_423_070 : int; 1_831_422_628 : int; 3_856_016_094 : principal }
       wire_type: table0, expect_type: variant {
         Upgrade : opt record {
           token_symbol : opt text;
           transfer_fee : opt nat64;
           metadata : opt vec record {
             text;
             variant { Int : int; Nat : nat; Blob : vec nat8; Text : text };
           };
           change_fee_collector : opt variant {
             SetTo : record { owner : principal; subaccount : opt vec nat8 };
             Unset;
           };
           max_memo_length : opt nat16;
           token_name : opt text;
           feature_flags : opt record { icrc2 : bool };
         };
         Init : record {
           token_symbol : text;
           transfer_fee : nat64;
           metadata : vec record {
             text;
             variant { Int : int; Nat : nat; Blob : vec nat8; Text : text };
           };
           minting_account : record { owner : principal; subaccount : opt vec nat8 };
           initial_balances : vec record {
             record { owner : principal; subaccount : opt vec nat8 };
             nat64;
           };
           fee_collector_account : opt record {
             owner : principal;
             subaccount : opt vec nat8;
           };
           archive_options : record {
             num_blocks_to_archive : nat64;
             max_transactions_per_response : opt nat64;
             trigger_threshold : nat64;
             max_message_size_bytes : opt nat64;
             cycles_for_archive_creation : opt nat64;
             node_max_memory_size_bytes : opt nat64;
             controller_id : principal;
           };
           max_memo_length : opt nat16;
           token_name : text;
           feature_flags : opt record { icrc2 : bool };
         };
       }
    1: table0 is not a subtype of variant {
         Upgrade : opt record {
           token_symbol : opt text;
           transfer_fee : opt nat64;
           metadata : opt vec record {
             text;
             variant { Int : int; Nat : nat; Blob : vec nat8; Text : text };
           };
           change_fee_collector : opt variant {
             SetTo : record { owner : principal; subaccount : opt vec nat8 };
             Unset;
           };
           max_memo_length : opt nat16;
           token_name : opt text;
           feature_flags : opt record { icrc2 : bool };
         };
         Init : record {
           token_symbol : text;
           transfer_fee : nat64;
           metadata : vec record {
             text;
             variant { Int : int; Nat : nat; Blob : vec nat8; Text : text };
           };
           minting_account : record { owner : principal; subaccount : opt vec nat8 };
           initial_balances : vec record {
             record { owner : principal; subaccount : opt vec nat8 };
             nat64;
           };
           fee_collector_account : opt record {
             owner : principal;
             subaccount : opt vec nat8;
           };
           archive_options : record {
             num_blocks_to_archive : nat64;
             max_transactions_per_response : opt nat64;
             trigger_threshold : nat64;
             max_message_size_bytes : opt nat64;
             cycles_for_archive_creation : opt nat64;
             node_max_memory_size_bytes : opt nat64;
             controller_id : principal;
           };
           max_memo_length : opt nat16;
           token_name : text;
           feature_flags : opt record { icrc2 : bool };
         };
       }
    2: Variant field 815_032_112: table1 is not a subtype of record {
         token_symbol : text;
         transfer_fee : nat64;
         metadata : vec record {
           text;
           variant { Int : int; Nat : nat; Blob : vec nat8; Text : text };
         };
         minting_account : record { owner : principal; subaccount : opt vec nat8 };
         initial_balances : vec record {
           record { owner : principal; subaccount : opt vec nat8 };
           nat64;
         };
         fee_collector_account : opt record {
           owner : principal;
           subaccount : opt vec nat8;
         };
         archive_options : record {
           num_blocks_to_archive : nat64;
           max_transactions_per_response : opt nat64;
           trigger_threshold : nat64;
           max_message_size_bytes : opt nat64;
           cycles_for_archive_creation : opt nat64;
           node_max_memory_size_bytes : opt nat64;
           controller_id : principal;
         };
         max_memo_length : opt nat16;
         token_name : text;
         feature_flags : opt record { icrc2 : bool };
       }
    3: Record field transfer_fee: int is not a subtype of nat64
    4: int is not a subtype of nat64), error code None

Any assistance in installing the ledger locally using the instructions provided on the website would be greatly appreciated.

Not a direct answer but, here’s how I deploy successfully the ICP ledger locally to develop Juno.
Maybe you can find something in the process that helps you?

  1. I find the account identifier of the ledger. To do I got a NodeJS script

https://github.com/buildwithjuno/juno/blob/main/scripts/ledger.account-id.mjs

  1. I update that identifier in my deploy script

https://github.com/buildwithjuno/juno/blob/main/scripts/ledger.sh

  1. I edit manually dfx.json to use the private did file of the ledger
"ledger": {
  "type": "custom",
  "wasm": "ledger.wasm",
  "candid": "ledger.private.did"
}
  1. I run my deploy script, the one I shared above ledger.sh

  2. I revert back the ledger definition in dfx.json

"ledger": {
			"type": "custom",
			"candid": "ledger.public.did",
			"wasm": "ledger.wasm",
			"remote": {
				"candid": "ledger.public.did",
				"id": {
					"ic": "ryjl3-tyaaa-aaaaa-aaaba-cai"
				}
			}
		},

That should be it.

In the script you will find the dfx deploy command that I use:

dfx deploy ledger --specified-id ryjl3-tyaaa-aaaaa-aaaba-cai --argument '(record {minting_account = "'${MINT_ACC}'"; initial_values = vec { record { "'${LEDGER_ACC}'"; record { e8s=100_000_000_000 } }; }; send_whitelist = vec {}})'

Note that this deploy command is most probably tight with the version of the wasm I used.
Commit it on the IC repo: f02cc38677905e24a9016637fddc697039930808

1 Like

We have a PR open that updates the Local Ledger Setup docs page with the latest instructions. The file with those new instructions can be seen here: https://github.com/dfinity/portal/blob/97c6333c77bfb37e39cae442860e5ffeeef13a71/docs/developer-docs/integrations/ledger/ledger-local-setup.md

1 Like

I will give these solutions a try!