JSPM

@emurgo/cip14-js

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

A Javascript library reference implementation for CIP14

Package Exports

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

Readme

CIP14-JS

On the Cardano blockchain, native assets are uniquely identified by both their policy id and asset name. Neither the policy id nor the asset name are intended to be human-readable data. CIP14 introduces an asset fingerprint which is a short(er) and human-readable identifier for assets that user can recognize and refer to when talking about assets.

More specifically, CIP14 defines a user-facing asset fingerprint as a bech32-encoded blake2b-160 digest of the concatenation of the policy id and the asset name.

This package is a Typescript implementation of CIP14

Install

npm i @emurgo/cip14-js --save

Usage

const AssetFingerprint = require('@emurgo/cip14-js');

// initialize class with policyId, assetName
const assetFingerprint = AssetFingerprint.fromParts(
  Buffer.from('1e349c9bdea19fd6c147626a5260bc44b71635f398b67c59881df209', 'hex'),
  Buffer.from('504154415445', 'hex'),
);

const fingerprintHash = assetFingerprint.hash();
const bech32Fingerprint = assetFingerprint.fingerprint();
// initialize class with bech32
const assetFingerprint = AssetFingerprint.fromBech32('asset1rjklcrnsdzqp65wjgrg55sy9723kw09mlgvlc3');

const fingerprintHash = assetFingerprint.hash();
const prefix = assetFingerprint.prefix();