The game Outer Wilds hold a very special place in my heart. I first encountered Outer Wilds when it was a student project in a very early release build, and when I was a simple-minded Grade 10…
Long story short, to convert ICP to cycles you need two things:
The description of the interface of the cycles-minting canister has to be used to initialize the communication channel.
In the following code snippets I use these particular bindings.
With 1 XDR being equal to 1 trillion cycles, I convert the result to trillion ratio before returning it.
We aim to convert readable numbers. That is why we first need a small utility that maps number
to BigInt
(because the conversion function will process such types).
A few samples of above function result (number -> bigint):
Finally, to effectively convert the ICP to cycles, we can implement a cross-multiplication with the conversion rate.
Put together in a small demo, e.g., above functions can be chained to log the result of the conversion to the console.
If run in a command line, the sample should output such a result:
I hope this small tutorial will be useful. If you have any idea of improvements, let me know!
To infinity and beyond
David
Israeli journalist Gil Tamari of Channel 13 reporting from Jeddah before a visit to the holy city of Mecca in Saudi Arabia (Screengrab/Channel 13) Saudi Arabian police in Mecca have arrested a…
The Secondary School Certificate (SSC) Exam is one of the most important exams for students in Bangladesh. It is the gateway to higher education, and a good performance in the exam can set the…
The LAMT token is the native token of the Lamina Trade platform. It is an evolutionary token that will power the market’s largest on-chain algorithm platform. Investing in the LAMT token presale…