Potential generalizable solutions for recovering funds that users accidentally send to their II app principal?

Just to share because it touches this subject;

We had a similar issue a while back where SNS neurons were distributed to a principal that wasn’t supporting interaction with neurons them so we wanted to transfer them, with the help of @peterparker we developed a solution for that, but it came in handy a couple of times so a couple of days ago somebody had the issue as described above for WTN tokens so a transfer function was added.

For now it only support internet identity for token transfers but others can be added easily;

How it works:
open up your chrome console and paste the following in (with the replaced params to fit your need)

const { transferToken } = await import("https://unpkg.com/yolosns-2@1.1.8/dist/esm/index.js")
await transferToken("LEDGER_CANISTER_ID", "SEND_TO_PRINCIPAL", BigInt(AMOUNT - FEE))

This is the method you are calling

So basically how it works,

  • you login with internet identity which sets a global identity on the dapp where your assets are sent to
  • the script uses that identity to run not-ui enabled methods (in this case a hardcoded icrc1_transfer)

This is based on “trust me bro” but everything is verifiable, so this might be something that comes in handy when developing a more generic solution.

4 Likes