Ledger-transfer demo cannot be deployed

export IC_VERSION=dd3a710b03bd3ae10368a91b255571d012d1ec2f
curl -o ledger.wasm.gz "https://download.dfinity.systems/ic/$IC_VERSION/canisters/ledger-canister_notify-method.wasm.gz"
gunzip ledger.wasm.gz
curl -o ledger.private.did "https://raw.githubusercontent.com/dfinity/ic/$IC_VERSION/rs/rosetta-api/ledger.did"

Some link addresses in it have expired, and my parameters are better and the latest IC_VERSION, but dfx deploy ledger --argument xxx, the argument has changed,
In the end I tried a lot of adjustments but couldn’t deploy successfully locally!

Can you help us update a new usable demo?

It seems that the argument rules of the new version have changed, and various errors still appear after trying to adjust. It took me a lot of time and made me very painful. I hope you can help me.
Thanks!

I got it to install with 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)\"}; }})"

Error reporting:

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: Unable to decode init argument.
Decode as new init returned the error No more values on the wire, the expected type variant {
  Upgrade : opt record {
    maximum_number_of_accounts : opt nat64;
    icrc1_minting_account : opt record {
      owner : principal;
      subaccount : opt vec nat8;
    };
  };
  Init : record {
    send_whitelist : vec principal;
    token_symbol : opt text;
    transfer_fee : opt record { e8s : nat64 };
    minting_account : text;
    transaction_window : opt record { secs : nat64; nanos : nat32 };
    max_message_size_bytes : opt nat64;
    icrc1_minting_account : opt record {
      owner : principal;
      subaccount : opt vec nat8;
    };
    archive_options : opt 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;
    };
    initial_values : vec record { text; record { e8s : nat64 } };
    token_name : opt text;
  };
} is not opt, reserved or null
Decode as old init returned the error No more values on the wire, the expected type record {
  send_whitelist : vec principal;
  token_symbol : opt text;
  transfer_fee : opt record { e8s : nat64 };
  minting_account : text;
  transaction_window : opt record { secs : nat64; nanos : nat32 };
  max_message_size_bytes : opt nat64;
  icrc1_minting_account : opt record {
    owner : principal;
    subaccount : opt vec nat8;
  };
  archive_options : opt 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;
  };
  initial_values : vec record { text; record { e8s : nat64 } };
  token_name : opt text;
} is not opt, reserved or null, error code None

If you use the latest ledger implementation, then some init parameters have changed and you’d need to adjust accordingly.

I’m using this ledger version:

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

Thank you! Successfully deployed!

But the ‘transfer’ interface function is no longer available, has it been replaced with ‘icrc1_transfer’ now?

service : (ledger_arg : LedgerArg) -> {
    icrc1_name : () -> (text) query;
    icrc1_symbol : () -> (text) query;
    icrc1_decimals : () -> (nat8) query;
    icrc1_metadata : () -> (vec record { text; MetadataValue }) query;
    icrc1_total_supply : () -> (Tokens) query;
    icrc1_fee : () -> (Tokens) query;
    icrc1_minting_account : () -> (opt Account) query;
    icrc1_balance_of : (Account) -> (Tokens) query;
    icrc1_transfer : (TransferArg) -> (TransferResult);
    icrc1_supported_standards : () -> (vec record { name : text; url : text }) query;
    get_transactions : (GetTransactionsRequest) -> (GetTransactionsResponse) query;
    get_blocks : (GetBlocksArgs) -> (GetBlocksResponse) query;  
    get_data_certificate : () -> (DataCertificate) query;    
}

Yes. I suggest you use the icrc1_transfer, but I think the original ‘transfer’ function may still be in the wasm, even though it’s not advertised anymore

1 Like

Regarding the “remote” in the configuration, I know it should be the ledger IC address, but how do I switch to call the ic ledger or the local ledger?
Or is it deployed to the IC network to automatically point to the ic ledger?

Correct. dfx build injects environment variables corresponding to the selected network’s canister ids, which the compiler(s) will pick up and hard-code into the wasm

1 Like