JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8827
  • Score
    100M100P100Q161221F
  • License MIT

CAIP standard utils

Package Exports

  • caip

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 (caip) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

caip npm version

CAIP standard utils

ChainID (CAIP-2)

Using Classes

import { ChainID } from "caip";

const chainId = new ChainID("eip155:1");

// OR

const chainId = new ChainID({ namespace: "eip155", reference: "1" });

// THEN

chainId.toString();
// "eip155:1"

chainId.toJson();
// { namespace: "eip155", reference: "1" }

Using Functions

import { ChainID } from "caip";

ChainID.parse("eip155:1");
// { namespace: "eip155", reference: "1" }

// AND

ChainID.format({ namespace: "eip155", reference: "1" });
// "eip155:1"

AccountID (CAIP-10)

Using Classes

import { AccountID } from "caip";

const accountId = new AccountID(
  "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb@eip155:1"
);

// OR

const accountId = new AccountID({
  address: "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb",
  chainId: { namespace: "eip155", reference: "1" },
});

// THEN

accountId.toString();
// "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb@eip155:1"

accountId.toJson();
// { address: "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb", chainId: { namespace: "eip155", reference: "1" } }

Using Functions

import { ChainID } from "caip";

ChainID.parse("0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb@eip155:1");
// { address: "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb", chainId: { namespace: "eip155", reference: "1" } }

// AND

ChainID.format({
  address: "0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb",
  chainId: { namespace: "eip155", reference: "1" },
});
//"0xab16a96d359ec26a11e2c2b3d8f8b8942d5bfcdb@eip155:1"