Skip to content

Add method for obtaining canonical inscription ID in docs? #4415

@arik-so

Description

@arik-so

The way the docs currently describe getting the inscription ID, it will not be deterministic due to explorers being case-insensitive and allowing leading 0s.

let inscription_id = window.location.pathname.split("/").pop();

Oftentimes, the inscription ID is used as a seed for pseudorandom outputs for generative collections, and results in inconsistencies across various viewers. Would it make sense to add a canonicalization function to the docs, such as below?

// this code is not optimized
function normalizeInscriptionId(input) {
  const m = String(input).trim().match(/^([0-9a-fA-F]{64})[iI]([0-9]+)$/);
  if (!m) throw new Error("Invalid format: expected <64-hex><i><decimal index>");

  const txid = m[1].toLowerCase();
  const index = BigInt(m[2]).toString();
  return `${txid}i${index}`;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions