mint_cycles/
lib.rs

1//! # ICP to Cycles Conversion Library
2//!
3//! ## Overview
4//!
5//! This Rust library provides a function to convert ICP tokens into cycles programmatically. This functionality is essential for scenarios where you need to manage and deploy canisters dynamically using the Rust CDK.
6//!
7//! ## Use Case
8//!
9//! One primary use case is when building canisters for users on the fly. In such cases, you need to add cycles to the canisters programmatically and deploy them automatically. The `dfx` CLI tool isn't suitable for this scenario since it is designed for manual interactions. Our library offers a programmatic solution for converting ICP tokens into cycles.
10//!
11//! ## Functionality
12//!
13//! ### `mint_cycles`
14//!
15//! The library includes a single function: `mint_cycles`. This function converts ICP tokens held by a canister into cycles.
16//!
17//! #### Function Signature
18//!
19//! ```rust
20//! fn mint_cycles(amount: Tokens)
21//! ```
22//!
23//! ##### Parameters
24//!
25//! `amount`: This parameter is of type `Tokens`, defined as:
26//!
27//! ```rust
28//! pub struct Tokens {
29//!     e8s: u64,
30//! }
31//! ```
32//!
33//! Refer to `ic_ledger_types::Tokens` for more details.
34//!
35//! ### Assumptions
36//!
37//! - The canister calling `mint_cycles` holds some ICP tokens.
38//! - Canisters can hold and transfer ICP tokens.
39//!
40//! Before calling `mint_cycles`, you can top up your main canister with ICP tokens using a wallet of your choice or any other method. This main canister can be used for automatically building and deploying other canisters.
41//!
42//! ### Example Workflow
43//!
44//! 1. **Top Up Main Canister**: Transfer ICP tokens to your main canister.
45//! 2. **Convert Tokens to Cycles**: Call `mint_cycles` with the desired amount of tokens to convert them into cycles.
46//! 3. **Deploy Canisters**: Use the cycles to build and deploy other canisters programmatically.
47//!
48//! ## Source Code
49//!
50//! For more details and to contribute, please refer to the source code.
51//!
52//! This library aims to simplify the process of converting ICP tokens into cycles for dynamic canister management and deployment. We hope this helps, and we look forward to your contributions.
53
54mod cmc;
55mod errors;
56mod ledger;
57mod transaction;
58pub mod rust_declarations {
59    pub mod cmc_service;
60    pub mod icp_ledger_service;
61}
62pub use transaction::mint_cycles;