Hi!
I have a few questions that are slowing down my project in development
I realized that there are nuances that are not visible at first glance.
I would like to clarify
There will be a lot of users on the site. They will need to finance their canisters. In the web interface mode.
Authorization will be via Plug wallet. (This is not particularly important, you can also Stoic or add from Definity)
I was trying to send (replace) cycles to the user’s canister. Writes that the balance in the wallet is 0.
Questions:
How to understand the IСP so that they Cycles would go to the same account.
How to send cycles to the canister from the account to the destination canister.
Do I need to finance a subaccount for this if it is needed?
I understand that the questions are vague, but in my vision it was initially like this: I put ICP into a Cycle mint canister and say I will profinase me or the canister I selected in exchange for ICP with newly created cycles. But this is not the case.
The same account is very difficult. ICP can be held on the ledger or many different wallets, cycles can only be held by canisters, or as XTC / otherwise wrapped cycles in wallets.
This depends on the wallet/mechanism you use.
I don’t quite understand your last question. I recommend you read through the following, and then try to ask some more specific questions.
Can’t tell you how to form this variable CMC_CREATE_ADDRESS ?
(I was trying to find a string search in github. Could not find any repository with a line of code containing CMC_CREATE_ADDRESS)
Yes, but it’s not YOU who’s initiating the transfer. It’s your canister, which has a separate balance. To compare yourself: dfx ledger account-id is your account, and dfx ledger account-id --of-principal $(dfx canister --network ic id <canister name>) will be your canister’s ledger account id.
And here’s what I wrote down in a different (non-public) place: main account = <CMC principal>, subaccount ~ <this canister's principal>. But do not use dfx ledger account-id to derive that, it'll end up wrong. Go through ic-ledger-types::AccountIdentifier::new to derive it.
I have more questions:
1)How do I get in motoko the address of a canister by its canister id ?
2) Now I was sending an ICP from my wallet can I program this for myself (in a simple case)
Ok. Thanks.I will also think about the implementation.
I had to send ICP to the destination canister via a plug-in wallet (Stoic or Plug or via terminal) but I would like the ability to send programmatically. I understand that a keychain is needed (that is, to sign a transaction) It’s not safe. I asked if you suddenly have options.
Options without any user interaction are rather limited. The first one that comes to mind is dfx with an unencrypted identity, but that leaves your private key on your disk in plain text. Alternatively, maybe it’s possible to automate some wallet, either through something like selenium (browser automation) or by doing dfx calls, which is probably what the wallets do in the background.
By far the safest way would probably be a canister that sends funds around when the need arises, using the heartbeat functionality. But that would not come out of your own balance, but from its own.
I’ve been wondering if the memo can be set to an arbitrary value? Or does it need to be CANISTER_CREATE_MEMO? If so what does this constant look like? And what would it look like for a top up?
if memo != expected_memo {
return Err(NotifyError::InvalidTransaction(format!(
"Intent in the block ({} == {}) different than in the notification ({} == {})",
memo.0,
memo_to_intent_str(memo),
expected_memo.0,
memo_to_intent_str(expected_memo),
)));
}