Skip to content
/ caip Public

Typescript typings and parsing of CAIP standards

License

Notifications You must be signed in to change notification settings

XLNT/caip

Repository files navigation

@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

About

Typescript typings and parsing of CAIP standards

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published