How to convert ICP to cycles programatically?

Hi,
Does anyone know a way to convert ICP to cycles using cycles minter canister ?
How can I interact with that canister from motoko ?
Any examples ?

Someone else could surely be of more help but as a starting point:

I’ve looked what the dfx ledger topup command does under the hood. The most interesting part is here:

So as far as I understand, you transfer ICP to a subaccount of the (Cycle Management Canister) which references the principal you want to send the cycles to and then you notify the CMC canister about it.

This means you have to call a function on the ledger canister and on the CMC canister from your canister in Motoko.

2 Likes