Crates.io | mint-cycles |
lib.rs | mint-cycles |
version | 0.1.0 |
source | src |
created_at | 2024-06-14 09:47:28.800001 |
updated_at | 2024-06-14 09:47:28.800001 |
description | Programatically convert ICP tokens into cycles in Rust |
homepage | |
repository | https://github.com/amschel99/mint-cycles |
max_upload_size | |
id | 1271808 |
size | 26,522 |
This library is supposed to be used in a canister environment
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.
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.
mint_cycles
The library includes a single function: mint_cycles
. This function converts ICP tokens held by a canister into cycles.
fn mint_cycles(amount: Tokens)
amount
: This parameter is of type Tokens, defined as:
pub struct Tokens {
e8s: u64,
}
Refer to ic_ledger_types::Tokens
for more details.
The canister calling mint_cycles holds some ICP tokens.
Canisters can hold and transfer ICP tokens. 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.
For more details and to contribute, please refer to the source code.
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.