1.0.1 • Published 1 year ago

@dcspark/cip34-js v1.0.1

Weekly downloads
-
License
Apache-2.0 OR MIT
Repository
github
Last release
1 year ago

CIP34-JS

A JS library for CIP34 that defines chain IDs for Cardano.

Example

Network nameCIP34 chain ID
PreProductioncip34:0-1
Mainnetcip34:1-764824073

Usage

Generate chain ID from registry data

import { toChainId } from "@dcspark/cip34-js";
import registry from "@dcspark/cip34-js/registry";

const chainId = toChainId({
  networkId: registry.Mainnet.NetworkId,
  networkMagic: registry.Mainnet.NetworkMagic,
});

Get parts from chain ID

import { fromChainId } from "@dcspark/cip34-js";

const { networkId, networkMagic } = fromChainId(chainId);

Updating

The current status of the registry is tracked inside the CIP repository. To keep things in sync, this project uses the CIP repo as a git submodule.

npm run update-submodule && npm run regen-types && npm run build