@xlnt/caip
v1.0.1
Published
This package provides Typescript typings and logic for reading and creating [CAIP](https://github.com/ChainAgnostic/CAIPs) identifiers, namespaces, and references.
Downloads
2
Readme
@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