3.0.4 • Published 12 hours ago

@dfinity/cmc v3.0.4

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
12 hours ago

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:

:factory: CMCCanister

Methods

:gear: create
MethodType
create(options: CMCCanisterOptions) => CMCCanister
:gear: getIcpToCyclesConversionRate

Returns conversion rate of ICP to Cycles

MethodType
getIcpToCyclesConversionRate() => Promise<bigint>
:gear: notifyCreateCanister

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

MethodType
notifyCreateCanister(request: NotifyCreateCanisterArg) => Promise<Principal>
:gear: notifyTopUp

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

MethodType
notifyTopUp(request: NotifyTopUpArg) => Promise<bigint>
3.0.4

14 days ago

3.0.3

2 months ago

3.0.2

3 months ago

3.0.1

3 months ago

3.0.0

3 months ago

2.1.0

5 months ago

0.0.15

9 months ago

0.0.16

9 months ago

0.0.17

8 months ago

0.0.18

8 months ago

0.0.14

11 months ago

2.0.0

6 months ago

1.0.0

7 months ago

0.0.9

1 year ago

0.0.10

1 year ago

0.0.11

12 months ago

0.0.12

11 months ago

0.0.13

11 months ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.3

1 year ago

0.0.2

2 years ago

0.0.1

2 years ago