CLI Local ICP transfer fails

Trying to transfer icp locally from default account to another account created using ii. Following those steps in cli:

didc encode ‘(principal “r5uhi-pmjl6-gxoha-f6n3z-iejyc-d7waz-fluec-ikt6z-bz5t5-dtuyi-jae”)’ -f blob
output:
blob “DIDL\00\01h\01\1d\89_\8dw\1c\05\f3w\94\118\10\ff\60d\ab\a1\04\85O\d9\0e{>\8et\c2\12\02”

dfx canister call ledger transfer ‘(record { amount = record { e8s = 100000 }; to = (blob “DIDL\00\01h\01\1d\89_\8dw\1c\05\f3w\94\118\10\ff\60d\ab\a1\04\85O\d9\0e{>\8et\c2\12\02”); fee = record { e8s = 10000}; memo = 1;})’

receiving the following error:
Error: The Replica returned an error: code 5, message: “Canister rrkah-fqaaa-aaaaa-aaaaq-cai trapped explicitly: Invalid account identifier: Checksum failed for 4449444c000168011d895f8d771c05f37794113810ff6064aba104854fd90e7b, expected check bytes 3fc33bde but found 4449444c”

Any clues on what i’m doing wrong?

Hey,

The ‘to’ parameter needs to be an account ID and not a principal. Have a look at step 4 here.

Thanks for the feedback. Tried it out and the transfer went though, though i couldn’t find the icp balance when trying out the defi example at:

The balance checks though when i query through the cli using:
dfx canister call ledger account_balance ‘(record { account = ‘$(python3 -c ‘print(“vec{” + “;”.join([str(b) for b in bytes.fromhex("‘346D98E619659C7492444F43984172CDC27D5B4B87FB893BC6B1C3A8F99EFC6D’")]) + “}”)’)’ })’

Output:
(record { e8s = 100_000 : nat64 })

One other question, how do i use the ledger candid interface, tried passing the ii and address and it gives error:
InputError: Cannot convert 346D98E619659C7492444F43984172CDC27D5B4B87FB893BC6B1C3A8F99EFC6D to a BigInt

I haven’t looked at the DeFi example in detail, but I guess you don’t use the same account ID in both cases. Remember and account ID is derived from a Principal but its not the Principal itself.

Not exactly sure what you mean. Which function did you use? But I tried to use the account_balance() of the ledger via candid UI myself recently and remember similar issues. Maybe @chenyan can help here?

I’m using the account id that appears here:

Is this the right one?

As for candid ui, yes i’m trying to use account_balance passing it ii and id but they both error out.

Looks good to me. Don’t see the issue right now. Have you tried what’s inside here: examples/motoko/defi/test/transfer.sh at 403c5f8291bd5c3bceb41c9affdd6d227c6683ca · dfinity/examples · GitHub ?

Would be interesting to see if this works and to look at the difference between the deposit addresses.

I tried the script and it worked fine, don’t know how to view the two created users in the ui though! Any clues on how i can access those accounts in the ui?

Couple of clarifications:
Users created in the ui are done using the ii ui. I wasn’t able to find a way to access those accounts in the cli, nor am i able to access users created using cli in the ui.
I was able to transfer tokens to the users appearing in the ui fine. The issue i’m facing is only with icp.

Found a solution for anyone walking through the thread:
Running the following added to the accounts balances:
make init-local II_PRINCIPAL=“7u6ki-yuwed-t4x77-4tl3q-hyhsm-6mnpg-3dk4o-ijvha-vp
3ua-5jgij-pqe”

Delving into the code, there is a script used to convert from principal to default account, which seems to have been the missing link i’ve been searching for.

1 Like