Skip to main content

ic-js

Intermediate
ic-js

ic-js is a collection of JavaScript libraries that can be used to interface with ICP. Each library can be used independently from one another, or a project can use all of the libraries together. The NNS dapp is an example demonstration of all ic-js libraries being used together.

Dependencies

ic-js uses @dfinity/agent (ICP JavaScript agent) and @dfinity/utils as peer dependencies. It is recommended to have these packages available in your project as well.

You can install them using npm:

npm i @dfinity/agent @dfinity/candid @dfinity/principal @dfinity/utils

Libraries

Governance

  • nns: Interface with the governance canisters of the Network Nervous System (NNS).

  • sns: Interface with a Service Nervous System (SNS) project.

  • nns-proto: The protobuf source used by nns-js to support hardware wallets.

You can install these libraries with npm:

npm i @dfinity/nns
npm i @dfinity/sns
npm i @dfinity/nns-proto

Tokens

  • cmc: Interface with the cycles minting canister (CMC).

  • ledger-icp: Interface with the ICP ledger.

  • ledger-icrc: Interface with ICRC-compatible ledgers.

  • ckBTC: Interface with ckBTC.

  • ckETH: Interface with ckETH.

You can install these libraries with npm:

npm i @dfinity/cmc
npm i @dfinity/ledger-icp
npm i @dfinity/ledger-icrc
npm i @dfinity/ckbtc
npm i @dfinity/cketh

Management canister

You can install this library with npm:

npm i @dfinity/ic-management

Utilities

  • utils: A collection of utilities and constants.

You can install this library with npm:

npm i @dfinity/utils