Hi Claudio, thanks for getting back to me. I have included the dfx temp files in my repo now if you would like to take a look. Kind regards, James
When I remove the line you suggest it imports but it seems that the function names are different from the defi example from the Dfinity examples. For instance Ledger.account_balance is now Ledger.account_balance_dfx.
Are there docs for me to look at where I can infer functionality for depositing ICP to a sub account, transferring to the default account and back again?
Kind regards, James
Iāve taken the ledger.public.did from here and it seems to have the functins I need:
Thanks for your help.
Sorry I didnāt respond in time but glad you found a solution.
No worries, thanks for the help.
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.
DFX version: 0.14.4
Guide followed: Ledger local setup | Internet Computer
Environment: Ubuntu 22.04.3 LTS
Problems in step 9 ( and a small one in step 1):
Step 1: Guide tells me to create new canister with name āledger-canisterā, but dfx in turn tells me that ā-ā is not allowed in the name. Fixed by making it āledgercanisterā and later renaming it
Step 9: The error this code gives can be seen in the screenshot. I tried filling in the Account ID manually, with and without brackets + assigning it first to another variable and then that variable to minting_account.
Any suggestions?
If I read the candid file correctly the account id is of type blob. You can find the syntax of declaring blobs here
Thanks for your response, I tried formatting it as blob in different ways but it didnāt work out. I see step 1 in the guide got updated, I hope same could be done for the code in step 9 according to the problem I showed and the breadcrumb by Severin.
(and maybe fix the not working wasm and did file download).
Iām now using the ledger_types package from MOPS, only downside is that this does not work in VSCode definitions as it wants you to call a deployed canister. If there is any other way to get the ledger working locally, id love to hear it.
Hey @wilak ,
I think your error may come from a lack of quotes around the principal ID. I tested it locally and was able to replicate your error when quotes arenāt used around those values.
Iāve created a PR to update the docs page to include quotes around those values, and clarify some of the steps such as the one regarding the Wasm download, per your feedback.
You can find the edited file here: https://github.com/dfinity/portal/blob/492fbda52bd0c0150942cc2ee4aa616fcf1c827c/docs/developer-docs/integrations/ledger/ledger-local-setup.md
Thanks!
Thank you very much for your prompt response! Got it working after refollowing the guide.
After following the guide I saw some small things that I had to figure out myself:
Step 10
mv ledger-canister.wasm.gz .dfx/canisters/ledger_canister/ledger-canister.wasm.gz
Its missing the /local/ dir &
In my case the canisters and ledger_canister dir were not yet made, so best if this was added (also cp, looking at step 12):
[ ! -d ".dfx/local/canisters/ledger_canister" ] && mkdir -p ".dfx/local/canisters/ledger_canister"
cp ledger-canister.wasm.gz .dfx/local/canisters/ledger_canister/ledger-canister.wasm.gz
Step 12
It said it couldnt find ledger-canister.wasm.gz, as it was looking in ./ and not ./.dfx/local/canisters/ledger_canister/
Thank you for the feedback @wilak ! Iāve made the suggested edits to the doc. Could you take another look and make sure I didnāt miss anything that you suggested?
Thanks!
Edits look good!, Only thing is that in step 11 it looks for ledger_canister.wasm.gz instead of ledger-canister.wasm.gz in the /local/canister/ledger_canister dir.
So I think best to rename it after the wget or during the mv, and then also rename it in dfx.jso
Thanks! Fixed that as well.
