npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

doken-precomputer

v0.0.5

Published

Precomputes Doken IDs

Readme

doken-precomputer

A utility library to precompute doken token identifiers

The Doken Precomputer is a TypeScript library designed to precompute Doken Identifiers for profiles, registries, and entries on a Cord Blockchain ecosystem. Previously, Doken Identifiers were generated dynamically and relied on event tracking due to their dependency on more than just account hashes or IDs. This library simplifies the process by enabling developers to precompute these identifiers efficiently, reducing reliance on event-based tracking and improving application layer performance. This was required since we moved from static to dynamic generation of identifiers based on genesis-network-id, pallet-index and many more prefixes.

This alleviates the fear of missing events for a particular transaction and reducing having overhead of extra watcher for every application running on top of CORD.

Installation

Install the library and its dependencies:

npm install doken-precomputer

or

yarn add doken-precomputer

Integration with SDK/App layer:

This repository is not a standalone SDK, but meant to work with existing application's/sdk's connected with CORD blockchain. Currently it supports generation of Doken URIs for following pallets: Profile, Registry & Entry.

Profile:

  • computeProfileDigest(api: ApiPromise, accountAddress: string): Promise<string>

    Computes a Blake2-256 hash (digest) for a profile based on the provided SS58 account address.

    Parameters: api: An ApiPromise instance connected to the blockchain. accountAddress: The SS58-encoded account address.

    Returns: A hex-encoded digest string used to create a Profile Doken ID.

  • computeProfileDokenId(api: ApiPromise, accountAddress: string): Promise<string | null>

    Computes a Profile Doken Identifier based on the account address. Validates the SS58 address and uses the profile digest to generate the identifier.

    Parameters: api: An ApiPromise instance. accountAddress: The SS58 account address.

    Returns: A Doken Identifier string or null if an error occurs.

Registry

  • computeRegistryDigest(api: ApiPromise, tx_hash: string, accountAddress: string): Promise<string>

    Computes a digest for a registry identifier using a transaction hash and the profile ID associated with the account address. Parameters:

    api: An ApiPromise instance. tx_hash: A hex-encoded transaction hash (32 bytes, e.g., 0x1234...). accountAddress: The SS58 account address.

    Returns: A hex-encoded digest string.

  • computeRegistryDokenId(api: ApiPromise, tx_hash: string, accountAddress: string): Promise<string | null>

    Computes a Registry Doken Identifier based on the transaction hash and account address.

    Parameters: api: An ApiPromise instance. tx_hash: A hex-encoded transaction hash. accountAddress: The SS58 account address.

    Returns: A Doken Identifier string or null if an error occurs.

Entry

  • computeEntryDigest(api: ApiPromise, tx_hash: string, registryId: string, accountAddress: string): Promise<string>

    Computes a digest for an entry identifier using a transaction hash, registry ID, and profile ID. Parameters: api: An ApiPromise instance. tx_hash: A hex-encoded transaction hash. registryId: The ID of the registry the entry is associated with. accountAddress: The SS58 account address.

    Returns: A hex-encoded digest string.

  • computeEntryDokenId(api: ApiPromise, tx_hash: string, registryId: string, accountAddress: string): Promise<string | null>

    Computes an Entry Doken Identifier based on the transaction hash, registry ID, and account address. Parameters: api: An ApiPromise instance. tx_hash: A hex-encoded transaction hash. registryId: The registry ID. accountAddress: The SS58 account address.

    Returns: A Doken Identifier string or null if an error occurs.

Example

import { ApiPromise, WsProvider } from '@polkadot/api';
import { 
  computeProfileDokenId, 
  computeRegistryDokenId, 
  computeEntryDokenId, 
  isValidAddress 
} from 'doken-precomputer';

async function main() {
  // Initialize the CORD API
  const provider = new WsProvider('wss://127.0.0.1:9944'); // Replace with required CORD Wss (Ex. Weavenet)
  const api = await ApiPromise.create({ provider });

  // Example inputs
  const accountAddress = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'; // Replace with valid SS58 address
  const txHash = '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef'; // Replace with valid tx hash
  const registryId = 'registry-123'; // Replace with valid registry ID

  try {
    // Compute Profile Doken ID
    const profileDokenId = await computeProfileDokenId(api, accountAddress);
    console.log('Profile Doken ID:', profileDokenId);

    // Compute Registry Doken ID
    const registryDokenId = await computeRegistryDokenId(api, txHash, accountAddress);
    console.log('Registry Doken ID:', registryDokenId);

    // Compute Entry Doken ID
    const entryDokenId = await computeEntryDokenId(api, txHash, registryId, accountAddress);
    console.log('Entry Doken ID:', entryDokenId);
  } catch (error) {
    console.error('Error:', error instanceof Error ? error.message : error);
  } finally {
    await api.disconnect();
  }
}

main();

Usage Cautions

  • Dynamic generation of URIs require the chain-state to be configured, meaning some of the prefixes required for generation of the final URI must be set, ex, the pallet-index for the required pallet say Profile must be called. Similarly other prefixes as well.
  • This can return Null is such cases, so handle gracefully.
  • To have maximum probability, run a test script with all required pallets once before using this repo on a new chain.