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

common-crypto-tools

v1.1.3

Published

#### Polkadot Typed Api was moved to another repository. [polkadot-typed-api](https://www.npmjs.com/package/polkadot-typed-api) #### EigenLayer Tools were moved to another repository. [eigenlayer-tools](https://www.npmjs.com/package/eigenlayer-tools)

Readme

Dynamic JSON Badge

The list of common tools for web3 and crypto

Polkadot Typed Api was moved to another repository. polkadot-typed-api

EigenLayer Tools were moved to another repository. eigenlayer-tools

Tools

  • abbreviateAddress - truncate address, like 0x387...dCE
  • addHTMLBreaksToAddress - add invisible breaks to string, to make it breakable
  • removeLeading0x - remove leading 0x from string, useful for logs parsing 0x387...dCE -> 387...dCE
  • toBigNumber - transform any digital value to EthersBigNumber
  • toBigFloat - transform any digital value to floated BigNumber
  • explorerUrl - generates blockchain explorer URLs for transactions, addresses, and blocks.

abbreviateAddress

Shortens blockchain addresses by keeping characters at the start and end, replacing the middle with symbols.

Parameters

  • address: The blockchain address to abbreviate.
  • options: Config for customization:
    • number: Sets characters to keep at start/end.
    • Options (object): Advanced settings like size, symbol, and ignore list.

Usage

Default

import { abbreviateAddress } from "common-crypto-tools";

abbreviateAddress("0x1234567890abcdef1234567890abcdef");
// Output: "0x1234...cdef"

Custom Size and Symbol

abbreviateAddress("0x1234567890abcdef1234567890abcdef", {
  size: { start: 4, end: 4 },
  symbol: "*",
  symbolsCount: 5,
});
// Output: "0x1234*****cdef"

Ignore List

abbreviateAddress("0x1234567890abcdef1234567890abcdef", {
  ignoreList: ["0x1234567890abcdef1234567890abcdef"],
});
// Output: "0x1234567890abcdef1234567890abcdef"

Advanced

abbreviateAddress("0x1234567890abcdef1234567890abcdef", {
  size: [2, 6],
  symbol: ".",
});
// Output: "0x12...cdef12"

addHTMLBreaksToAddress

The addHTMLBreaksToAddress function adds invisible HTML breaks to a string (e.g., a blockchain address) at regular intervals, making it more readable or ensuring proper wrapping in HTML contexts.

Parameters

  • address (string): The input string to format. Defaults to an empty string.
  • lettersBeforeSpace (number): The number of characters between each inserted invisible space. Must be a positive number.

Returns

A string with invisible HTML breaks added at the specified intervals.

Usage

Default Usage

import { addHTMLBreaksToAddress } from 'common-crypto-tools';

console.log(addHTMLBreaksToAddress("0x1234567890abcdef"));
// Output: "0x123​4567​890a​bcde​f"

Custom Interval

console.log(addHTMLBreaksToAddress("0x1234567890abcdef", 6));
// Output: "0x1234&#8203567890&#8203abcdef"

Error Handling

try {
  addHTMLBreaksToAddress("0x1234567890abcdef", -1);
} catch (error) {
  console.error(error.message);
  // Output: "Param lettersBeforeSpace is to small: -1"
}

removeLeading0x

Removes the 0x prefix from a string if it exists.

Parameters

  • data (string): Input string.

Returns

A string without the 0x prefix, or the original string if no prefix is found.

Examples

removeLeading0x("0x123456"); // "123456"
removeLeading0x("123456");   // "123456"
removeLeading0x("0x");       // ""

toBigNumber

Converts a BigNumberish value into an Ethers BigNumber instance.

Parameters

  • value (BigNumberish): The input value to convert. Can be a number, string, or other compatible type.

Returns

An Ethers BigNumber instance representing the input value.

Examples

import { toBigNumber } from 'common-crypto-tools';

// Convert number
console.log(toBigNumber(123).toString());
// Output: "123"

// Convert string
console.log(toBigNumber("456").toString());
// Output: "456"

// Convert hex string
console.log(toBigNumber("0x1a").toString());
// Output: "26"

toBigFloat

Converts a value (BigNumber, Ethers BigNumber, or other valid input) into a BigNumber instance for consistent floating-point operations.

Parameters

  • value (BigNumber.Value | EthersBigNumber): The input value to convert. Supports BigNumber-compatible formats or Ethers BigNumber.

Returns

A BigNumber instance representing the input value.

Examples

import { toBigFloat } from 'common-crypto-tools';
import { BigNumber as EthersBigNumber } from 'ethers';

// Convert Ethers BigNumber
const ethersValue = EthersBigNumber.from("1000000000000000000");
console.log(toBigFloat(ethersValue).toString());
// Output: "1000000000000000000"

// Convert number
console.log(toBigFloat(123.456).toString());
// Output: "123.456"

// Convert string
console.log(toBigFloat("12345.6789").toString());
// Output: "12345.6789"

explorerUrl

The explorerUrl function generates blockchain explorer URLs for transactions, addresses, and blocks. It supports multiple blockchain networks and allows customization of the base URL and paths.

Features

  • Generates URLs for transactions, addresses, and blocks.
  • Supports Ethereum, Arbitrum, Polygon, Binance Smart Chain, Optimism, Fantom, Avalanche, Solana, Tron, and Cosmos.
  • Allows customization of the base URL and path segments.

Usage

Basic Usage

import { explorerUrl } from 'common-crypto-tools';

// Ethereum Explorer
const ethExplorer = explorerUrl("ethereum");
console.log(ethExplorer.tx("0x123")); // Output: https://etherscan.io/tx/0x123
console.log(ethExplorer.address("0xabc")); // Output: https://etherscan.io/address/0xabc
console.log(ethExplorer.block(123456)); // Output: https://etherscan.io/block/123456

// Polygon Explorer
const polygonExplorer = explorerUrl("polygon");
console.log(polygonExplorer.tx("0x456")); // Output: https://polygonscan.com/tx/0x456

Customization

// Custom Ethereum Explorer
const customEthExplorer = explorerUrl("ethereum", {
  base: "https://custom.etherscan.io",
  tx: "transaction",
  address: "addr",
  block: "blk",
});

console.log(customEthExplorer.tx("0x123")); // Output: https://custom.etherscan.io/transaction/0x123
console.log(customEthExplorer.address("0xabc")); // Output: https://custom.etherscan.io/addr/0xabc
console.log(customEthExplorer.block(123456)); // Output: https://custom.etherscan.io/blk/123456

Error Handling

// Unsupported Network
try {
  explorerUrl("unknown");
} catch (error) {
  console.error(error.message); // Output: "Unsupported network: unknown"
}