I wrote a small sample showing how one can accepts cycles donation from ICP users.
Code: GitHub - ninegua/tipjar: ICP donation deposited as Cycles
It showcases that the frontend code is free to create any identities and call into the ledger canister.
The current limitation is that the canister itself has no idea of how many cycles it has received from the user. Although the frontend can perhaps calculate it, the backend canister still cannot verify such claims with a proof. So it is only suitable for accepting donations, not payments.
This is awesome! Can you walk us through the flow a bit?
It looks like you
- Create a new Identity and put it in web storage.
- Then if I send ICP to that account it will detect it and call topup with your tipjar ID as the recipient of the cycles
- This sends the dfx to the minting canister with the top up memo
- Then you notify the minting canister of your transaction with the tipjar canister as your to_subaccount
- Cycle minting canister gives you the cycles.
Awesome example. It cleared some things up for me. I thought the to_canister was a principal and to_subAccount had to be a sub account of that canister. I wish they had chosen different words. It is kind of confusing.