@dfinity/cmc
TypeScript icon, indicating that this package has built-in type declarations

3.0.3 • Public • Published

cmc-js

A library for interfacing with the cycle minting canister.

npm version GitHub license

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 @dfinity/agent @dfinity/candid @dfinity/principal @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();

Features

cmc-js implements following features:

🏭 CMCCanister

🔗 Source

Methods

⚙️ create
Method Type
create (options: CMCCanisterOptions) => CMCCanister

🔗 Source

⚙️ getIcpToCyclesConversionRate

Returns conversion rate of ICP to Cycles

Method Type
getIcpToCyclesConversionRate () => Promise<bigint>

🔗 Source

⚙️ notifyCreateCanister

Notifies Cycles Minting Canister of the creation of a new canister. It returns the new canister principal.

Method Type
notifyCreateCanister (request: NotifyCreateCanisterArg) => Promise<Principal>

🔗 Source

⚙️ notifyTopUp

Notifies Cycles Minting Canister of new cycles being added to canister. It returns the new Cycles of the canister.

Method Type
notifyTopUp (request: NotifyTopUpArg) => Promise<bigint>

🔗 Source

Package Sidebar

Install

npm i @dfinity/cmc

Weekly Downloads

1,576

Version

3.0.3

License

Apache-2.0

Unpacked Size

82.2 kB

Total Files

31

Last publish

Collaborators

  • dfx-json
  • dfn_wndlng
  • nathan.mcgrath.dfinity
  • frederikrothenberger
  • bitdivine
  • ielashi
  • dayyildiz
  • eric-swanson-dfinity
  • krpeacock
  • npm-dfinity-org