npm.io
9.1.0 • Published 8 months ago

@dfinity/ledger-icp

Licence
Apache-2.0
Version
9.1.0
Deps
0
Size
19 kB
Vulns
0
Weekly
0
Stars
82

ledger-icp-js

A library for interfacing with the ICP ledger on the Internet Computer.

npm version GitHub license

This library is meant to interface with the ICP ledger only. If you are looking to interact with Snses, ckBTC, or other ICRC tokens, use the ledger-icrc-js library.

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

Table of contents

Installation

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

npm i @dfinity/ledger-icp

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 IcpLedgerCanister. It has to be instantiated with a canister ID.

e.g. fetching a token metadata.

import { createAgent } from "@dfinity/utils";
import { IcpLedgerCanister } from "@dfinity/ledger-icp";

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

const { metadata } = IcpLedgerCanister.create({
  agent,
  canisterId: MY_LEDGER_CANISTER_ID,
});

const data = await metadata({});

Documentation

You can find the API docs here.

Resources

Keywords