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 🙏

© 2025 – Pkg Stats / Ryan Hefner

r2c-wallet-validator

v1.4.0

Published

A comprehensive and lightweight utility to validate cryptocurrency wallet addresses across multiple chains like EVM, Solana, Bitcoin, Polkadot, and Cosmos. Built for high performance and accuracy.

Downloads

1,901

Readme

Multi-Chain Crypto Wallet Address Validator (r2c-wallet-validator)

r2c-wallet-validator is a comprehensive, lightweight, and high-performance utility to validate cryptocurrency wallet addresses across multiple blockchains. Built for Web3 developers, DApps, and crypto exchanges who need reliable address validation.

Maintained by Road2Crypto.com.

Build and Test CodeQL Publish Package npm version License: MIT

Table of Contents

Features

  • 🚀 Multi-Chain Support: Validate addresses for EVM (Ethereum, Polygon, BSC), Solana, Bitcoin, Polkadot, Cosmos, TRON, and Cardano.
  • 📦 Zero Dependencies: Exceptionally lightweight and bloat-free.
  • 🌳 Tree-Shakable: Optimized for modern bundlers (Webpack, Rollup, Vite) with sideEffects: false.
  • High Performance: Regex-based and algorithmic validation for maximum speed.
  • 🛡️ TypeScript: Native TypeScript support with comprehensive type definitions (.d.ts).
  • 🔍 Detailed Errors: Granular error reporting for easier debugging and UI feedback.
  • Supported chains: Chains

Installation

npm install r2c-wallet-validator
# or
yarn add r2c-wallet-validator
# or
pnpm add r2c-wallet-validator

Usage

Basic Example

// Simple validation example
import { isWalletValid } from "r2c-wallet-validator";

const result = isWalletValid("0x742d35Cc6634C0532925a3b844Bc454e4438f44e");

if (!result.valid) {
  console.error("Error message:", result.error?.message);
} else {
  console.log("Wallet address type:", result.type); // WalletType.EVM
}

Advanced Example

// Advanced usage with all supported address types
import {
  isWalletValid,
  ValidationErrorMessage,
  WalletType,
} from "r2c-wallet-validator";

// 1. Validate specific chains (only check Bitcoin and EVM)
const specificResult = isWalletValid(
  "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
  {
    chains: [WalletType.BITCOIN, WalletType.EVM],
  }
); // Valid, type: EVM

// 2. Validate against a single specific chain
const singleChainResult = isWalletValid("InvalidBitcoin", {
  chains: [WalletType.BITCOIN],
}); // Invalid

const addresses = [
  "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", // EVM
  "3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy", // Bitcoin
  "9A5oG2fXhxpBnh9qVHVk3dxp4Up1gkp8q5vj5rwiUJr", // Solana
  "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", // TRON
  "cosmos1hsk6jryyqjfhp5dhc55tc9jtckygx0eph6dd02", // Cosmos
  "invalid_address",
];

addresses.forEach((address) => {
  const result = isWalletValid(address);
  if (!result.valid) {
    switch (result.error?.message) {
      case ValidationErrorMessage.EMPTY_ADDRESS:
        console.log(`Address: ${address} is invalid: Address is empty.`);
        break;
      case ValidationErrorMessage.INVALID_ADDRESS:
        console.log(
          `Address: ${address} is invalid: Address format is incorrect.`
        );
        break;
      default:
        console.log(`Address: ${address} is invalid.`);
        break;
    }
  } else {
    switch (result.type) {
      case WalletType.EVM:
        console.log(`Address: ${address} is valid and of type EVM.`);
        break;
      case WalletType.SOLANA:
        console.log(`Address: ${address} is valid and of type Solana.`);
        break;
      case WalletType.BITCOIN:
        console.log(`Address: ${address} is valid and of type Bitcoin.`);
        break;
      case WalletType.COSMOS:
        console.log(`Address: ${address} is valid and of type Cosmos.`);
        break;
      case WalletType.TRON:
        console.log(`Address: ${address} is valid and of type TRON.`);
        break;
      default:
        console.log(`Address: ${address} is valid but of unknown type.`);
        break;
    }
  }
});

API Reference

Functions

isWalletValid(address: string, options?: ValidationOptions): WalletValidationResponse

Validates a cryptocurrency wallet address.

Parameters:

  • address (string): The cryptocurrency wallet address to validate.
  • options (optional): Configuration object.
    • chains (WalletType[]): Array of allowed wallet types to validate against. If provided, the address must match one of the specified types.

isAddress(address: string, options?: ValidationOptions): boolean

Checks if a cryptocurrency wallet address is valid. Returns true if valid, false otherwise.

Parameters:

  • address (string): The cryptocurrency wallet address to validate.
  • options (optional): Configuration object.
    • chains (WalletType[]): Array of allowed wallet types to validate against. If provided, the address must match one of the specified types.

Returns:

  • WalletValidationResponse: An object containing validation results:
    • When valid: { valid: true, type: WalletType }
    • When invalid: { valid: false, error: { statusCode: number, message: ValidationErrorMessage } }

Types

ValidationErrorMessage

enum ValidationErrorMessage {
  EMPTY_ADDRESS = "The provided address is empty.",
  INVALID_ADDRESS = "The provided address does not match any supported wallet address patterns.",
}

WalletType

enum WalletType {
  EVM = "evm",
  SOLANA = "solana",
  BITCOIN = "bitcoin",
  COSMOS = "cosmos",
  TRON = "tron",
}

WalletValidationResponseError

interface WalletValidationResponseError {
  statusCode: number;
  message: ValidationErrorMessage;
}

WalletValidationResponse

interface WalletValidationResponse {
  valid: boolean;
  type?: WalletType;
  error?: WalletValidationResponseError;
}

ValidationOptions

interface ValidationOptions {
  chains?: WalletType[];
}

Supported Chains

| Chain | Description | Example Address | | -------- | ---------------------------------------------------------------------------------- | -------------------------------------------------------------------- | | EVM | Ethereum, Polygon, BSC, Arbitrum, Optimism, and other EVM-compatible chains | 0x742d35Cc6634C0532925a3b844Bc454e4438f44e | | Solana | Solana blockchain addresses (strict 32-byte Base58 public keys) | 9A5oG2fXhxpBnh9qVHVk3dxp4Up1gkp8q5vj5rwiUJr | | Bitcoin | Bitcoin addresses (Legacy and SegWit) | 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy | | Cosmos | Cosmos Hub and other Cosmos ecosystem chains | cosmos107ws4033624838304933629538356788950853 | | TRON | TRON mainnet (Base58Check T... or hex 41... with optional 0x prefix) | TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t | | Cardano | Cardano addresses (Shelley addr1..., stake1... and Byron Ae2..., DdzFF...) | addr1q9... | | Polkadot | Polkadot Mainnet addresses (SS58 format starting with 1) | 131MmXTN7xzy6wcb9di1JgChVoGjBfXMpphcGkGT6btu5YTo | | Litecoin | Litecoin addresses (Legacy L..., P2SH M.../3..., Bech32 ltc1...) | ltc1q063s48wwx45y2y7zz6pf70x96009942d93g3k5 | | Dogecoin | Dogecoin addresses (Legacy D..., Multisig A.../9...) | DS76q997iL4d4c539k7fA6k4q997iL4d4c | | Sui | Sui addresses (Hex 0x..., approx 66 chars) | 0x1a052c15a0c3241b1842b1096053f0b2a8d3ccdd5a747926b471e956bc1b38f8 | | Aptos | Aptos addresses (Hex 0x..., approx 66 chars) | 0x83e24403164007f3544d03e92e5e1e76b1f236e7a63d91f24d9c4912e75e927c | | TON | TON addresses (Base64-like E.../U.../k.../0... 48 chars) | EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8GB0aH |

Contributing

All contributions are welcome! Please feel free to open a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.