JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q52251F
  • License Apache-2.0 OR MIT

A Javascript library reference implementation for CIP34

Package Exports

  • @dcspark/cip34-js
  • @dcspark/cip34-js/index.js
  • @dcspark/cip34-js/registry
  • @dcspark/cip34-js/registry.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@dcspark/cip34-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

CIP34-JS

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

Example

Network name CIP34 chain ID
PreProduction cip34:0-1
Mainnet cip34: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.

To use the latest version of the registry,

  1. git submodule init
  2. git submodule update
  3. (whenever you want to update afterwards) npm run update-submodule