Dfx ledger top-up sent ICP instead of cycles

Hi, not sure if this is the right place to ask, but we’ve recently had a problem with topping up our canister which led to potentially lost funds:

So, the canister ran out of cycles, and to top up I sent some ICP to my ledger and then topped it up with:

dfx ledger top-up --amount 3536000000 <canister_id> --network ic and status still says its out of cycles, and that it needs at least additional 359M cycles

But before I topped it up it was asking for 230M cycles on the status command.

After further looking into it, I can see that what ended up happening is that instead of converting to cycles and depositing them, the command ended up just sending the ICP to presumably the canister’s ledger address?

This is the transaction I found on the explorer:

Canister ID: sue3z-uiaaa-aaaal-adfpq-cai

Is there something I can do to recover the funds or convert them to cycles so the canister can run?

1 Like

Hello @alex_kaffetzakis!

You can view this detailed reference on the dfx ledger top-up command.

As explained in the doc, dfx ledger top-up is a command to top up a canister with cycles minted from ICP tokens. It cannot only send ICP to the canister.

A couple of things that might be helpful:

  1. Are you sure that the command did not result in an error?

This command attempts to send 3536000000 ICP to the canister.
dfx ledger top-up --amount 3536000000 <canister_id> --network ic

I wish you had but doubt that you had this amount in your account. The command line should have returned an error similar to this:

Error: Failed to transfer funds.
Caused by: Failed to transfer funds.
The debit account doesn't have enough funds to complete the transaction, current balance: 0.10000000 ICP
  1. Could you have topped up the wrong canister?

Based on the transaction details that you provided, there is a possibility that you did top up a canister with 3536000000 ICP in E8S value (which is 3.53 ICP).

I think what might be confusing is that explorers and the IC data dashboard might show that x ICP is being sent from your ICP account ID to the canister’s principal ID.

For example, my account ID is 96cd8d62a91d777892a568a4093e7c250aceab7e6f82b3e1d3a6b5282eda3563 and I ran this command to send 0.00001 ICP to canister zndrp-vqaaa-aaaao-a3i6a-cai on mainnet.

dfx ledger top-up --amount 0.00001 zndrp-vqaaa-aaaao-a3i6a-cai --network ic

On the ICP data dashboard, this is going to show that 96cd8d62a91d777892a568a4093e7c250aceab7e6f82b3e1d3a6b5282eda3563 sent 0.00001 from to the canister’s account address: 3c86d912ead6de7133b9f787df4ca9feee07bea8835d3ed594b47ee89e6cb730:
Transaction: 6c466981423f5c9496f486a215628aa2f8f35d584a05ed309978e63506a34cab - ICP Dashboard.

For more troubleshooting, I would suggest:

  1. Get the account address that you believe that you used to send ICP to cycles to the canister.

dfx ledger account-id

  1. Get the canister’s account address:
  1. Then search for your account address on the IC Data Dashboard.

Do you see the intended transaction under the ICP Transaction section?

It should be from your account address to the canister module hash.

Hope that helps! Please do reply with any details that you may have uncovered from this!

3 Likes

I can confirm the command sent whatever ICP I had in my ledger to the canister’s address (?).

I found the transaction on the dashboard as well: Transaction: 8965b2d62fbf9b575438e6f9aecc9392e1b342e17c7e993ec0de755f49c010ea - ICP Dashboard

And I am not sure how to make sure the address is the canister cause the links on the reference you shared are broken, but I didn’t send any transactions elsewhere and I am 100% sure. The only command I ran was that, and I checked my balance before and after.

Now, I think I know what the issue could be, as at the same time I was running some stuff which could potentially have sent a stop signal to the terminal and could result in the command being interrupted midway. And it’s more evident when I consider that there was no output at all.

Someone on the discord suggested I would install code on the canister to send the ICP back, and I think I will try that, but if you have any other way I could do that, then I would love to know. E.g. if I could get the private key of the canister’s address and switch to that account (not sure at all if something like that is possible)

Hello Alex,

Thank you for digging a bit deeper.

The transaction that you provided has a memo: 1347768404 which is the memo for a proper cycles top-up.

What happens when you run this command in the root of your repo?

dfx canister status <canister_name> --network ic

I see that you sent me a DM so we can continue the conversation there as well.

The status says that the canister is out of cycles. And now the amount it asks for is 43 billion cycles rather than 230 million like yesterday. (Mind the misspell in the screenshot, character lost from stretching the window but the command was written correctly and ran correctly)

Can you please make sure there is “c” in canister"

dfx canister status isotopic_icp_store_backend --network ic

There is, the command ran normally, the screenshot doesn’t show the ‘c’ cause I resized the terminal window which can lose characters after new-lines.

2 Likes