Polkadot Apps
    Preparing search index...
    • Convert a planck (smallest indivisible token unit) value to a human-readable decimal string.

      Substrate chains store all token amounts as integer planck values. This function converts them to human-readable form (e.g. 10_000_000_000n"1.0" for DOT with 10 decimals). Trailing zeros are trimmed but at least one fractional digit is always shown.

      Parameters

      • planck: bigint

        The raw planck value as a bigint. Must be non-negative.

      • decimals: number = 10

        Number of decimal places for the token (default: 10 for DOT).

      Returns string

      A decimal string representation (e.g. "1.5", "0.0001").

      If planck is negative or decimals is invalid.

      import { formatPlanck } from "@polkadot-apps/utils";

      formatPlanck(10_000_000_000n); // "1.0" (10 decimals, DOT default)
      formatPlanck(15_000_000_000n); // "1.5"
      formatPlanck(1_000_000_000_000n, 12); // "1.0" (12 decimals, e.g. Polkadot relay)
      formatPlanck(0n); // "0.0"