npm.io
10.0.0 • Published 5d ago

@dfinity/cmc

Licence
Apache-2.0
Version
10.0.0
Deps
0
Size
16 kB
Vulns
0
Weekly
0
Stars
81

cmc-js

A library for interfacing with the cycle minting canister.

npm version GitHub license

Still using @dfinity/cmc? Upgrade to @icp-sdk/canisters/cmc!

Table of contents

Installation

You can use cmc-js by installing it in your project.

npm i @dfinity/cmc

The bundle needs peer dependencies, be sure that following resources are available in your project as well.

npm i @icp-sdk/core @dfinity/utils

Usage

The features are available through the class CmcCanister. It has to be instantiated with the canister ID of the cycles minting canister. On mainnet, its ID is rkp4c-7iaaa-aaaaa-aaaca-cai.

e.g. querying the current Icp to cycles conversion rate.

import { CmcCanister } from "@dfinity/cmc";
import { createAgent } from "@dfinity/utils";

const agent = await createAgent({
  identity,
  host: HOST,
});

const { getIcpToCyclesConversionRate } = CmcCanister.create({
  agent,
  canisterId: CYCLES_MINTING_CANISTER_ID,
});

const rate = await getIcpToCyclesConversionRate();

Documentation

You can find the API docs here.

Keywords