@xlnt/caip
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@xlnt/caip

This package provides Typescript typings and logic for reading and creating CAIP identifiers, namespaces, and references.

yarn add @xlnt/caip

Usage

import { parseIdentifier } from '@xlnt/caip';

const {
  chainId, // eip155:1
  assetNamespace, // erc721
  assetReference, // 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d
  tokenId, // ethers.BigNumber.from('771769')
} = parseIdentifier('eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769')
const reference = parseIdentifier('eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d/771769');
console.log(isAssetIDReference(reference)) // true, reference is AssetID
const reference = parseIdentifier('eip155:1/erc721:0x06012c8cf97BEaD5deAe237070F9587f8E7A266d');
console.log(isAssetIDReference(reference)) // false, reference is AssetType

Readme

Keywords

none

Package Sidebar

Install

npm i @xlnt/caip

Weekly Downloads

1

Version

1.0.1

License

Apache-2.0

Unpacked Size

75.1 kB

Total Files

50

Last publish

Collaborators

  • shrugs
  • xlnt-matt