4.0.0 • Published 7 months ago

@dfinity/cmc v4.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months 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

:link: Source

Methods

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

:link: Source

:gear: getIcpToCyclesConversionRate

Returns conversion rate of ICP to Cycles

MethodType
getIcpToCyclesConversionRate() => Promise<bigint>

:link: Source

: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>

:link: Source

: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>

:link: Source

:gear: getDefaultSubnets

This function calls the get_default_subnets method of the CMC canister, which returns a list of default subnets as Principal objects. It can be called as query or update.

MethodType
getDefaultSubnets({ certified }?: QueryParams) => Promise<Principal[]>

Parameters:

  • params: - The query parameters for the call.
  • params.certified: - Determines whether the response should be certified (default: non-certified if not specified).

:link: Source

4.0.0

8 months ago

3.2.2

8 months ago

3.2.1

9 months ago

3.1.0

11 months ago

3.2.0

9 months ago

3.0.7

1 year ago

3.0.6

1 year ago

3.0.5

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago

2.1.0

1 year ago

0.0.15

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.14

2 years ago

2.0.0

2 years ago

1.0.0

2 years ago

0.0.9

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago