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

@chrom-ar/utils

v0.1.4

Published

Chrom.ar utils

Downloads

5

Readme

@chrom-ar/utils

Version License

Utility functions used across Chrom.ar projects.

Installation

npm install @chrom-ar/utils
# or
yarn add @chrom-ar/utils

Usage

Token helpers

import { getTokenAddress, getTokenDecimals, getTokenAmount } from "@chrom-ar/utils";

const chain = "base";
const token = "USDC";

const address = getTokenAddress(chain, token); // "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
const decimals = getTokenDecimals(chain, token); // 6
const amount = getTokenAmount("42", chain, token); // "42000000"

Chain helpers

import { getChainId, getChainName, getEnvironment } from "@chrom-ar/utils";

getChainId("base"); // 8453
getChainName("mainnet"); // "ethereum"
getEnvironment("optimism"); // "Mainnet"

Prices

import { getTokenPrice } from "@chrom-ar/utils";

// USDC, you can get the address by calling getTokenAddress, see above
const price = await getTokenPrice("base", "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913");

Logger

import { logger, setLogger } from "@chrom-ar/utils";

setLogger({
  ...console,
  success: (msg: string) => console.log("SUCCESS:", msg),
});

logger.info("Ready");

API Reference

Token Functions

  • getTokenAddress(chain: string, token: string): string | null Returns the token address for the specified chain and token symbol.

  • getTokenDecimals(chain: string, token: string): number | null Returns the number of decimals for the specified token on the given chain.

  • getTokenAmount(amount: string, chain: string, token: string): string | null Converts a human-readable amount to raw token units based on token decimals.

  • getTokenInfo(network?: string, address?: string): { chainId: number, symbol: string, decimals: number } Returns token information for a given network and address.

Chain Functions

  • getChainId(network: string): ChainId Returns the chain ID for the given network name.

  • getChainName(chain: string): string | null Returns the standardized chain name for the given chain identifier.

  • isEvmChain(chain: string): boolean Checks if the specified chain is an EVM-compatible chain.

  • getEnvironment(chain: string): "Mainnet" | "Testnet" | "Devnet" | null Returns the environment type for the given chain.

  • getAlchemyChainName(chain: string): string | null Returns the Alchemy-specific chain name for the given chain.

Price Functions

  • getTokenPrice(network: string, tokenAddress: string, currency?: string): Promise Retrieves the current price of a token in the specified currency (default: USD).

  • getTokenPrices(network: string, tokenAddresses: string[], currency?: string): Promise<Record<string, number>> Retrieves prices for multiple tokens in the specified currency (default: USD).

Logger Functions

  • logger: Logger The global logger instance with methods: debug, info, error, warn, and success.

  • setLogger(customLogger: Logger): void Sets a custom logger implementation.

  • resetLogger(): void Resets the logger to the default implementation.

Development

npm run lint
npm run build