chain-address-validation
TypeScript icon, indicating that this package has built-in type declarations

0.4.0 • Public • Published

Npm package version Test Build & Publish GitHub latest commit Npm package yearly downloads

chain-address-validation

A TypeScript library for validating various cryptocurrency addresses.

Installation

You can install this package using npm or yarn:

npm install chain-address-validation

or

yarn add chain-address-validation

Usage

To use this library, import the desired validation function and call it with the address you want to validate.

Here's an example of how to validate Bitcoin addresses:

import { validateBitcoinAddress } from "chain-address-validation";

const address = "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";

if (validateBitcoinAddress(address)) {
  console.log("Valid Bitcoin address");
} else {
  console.log("Invalid Bitcoin address");
}

This library currently supports the following cryptocurrencies:

  • Chain Agnositic - validates the formatting of any of the supported chains
import { validateAddress } from "chain-address-validation";
  • Bitcoin (BTC)
import { validateBitcoinAddress } from "chain-address-validation";
  • Ethereum (ETH)
import { validateEthereumAddress } from "chain-address-validation";
  • Litecoin (LTC)
import { validateLitecoinAddress } from "chain-address-validation";
  • Bitcoin Cash (BCH)
import { validateBitcoinCashAddress } from "chain-address-validation";
  • Dash (DASH)
import { validateDashAddress } from "chain-address-validation";
  • Dogecoin (DOGE)
import { validateDogeAddress } from "chain-address-validation";
  • Solana (SOL)
import { validateSolanaAddress } from "chain-address-validation";
  • Cardano (ADA)
import { validateCardanoAddress } from "chain-address-validation";

You can import and use the respective validation functions for each of these cryptocurrencies.

Testnet Support

Each respective validation function offers a secondary argument for "networkType." Options include

  • "*" (default)
  • "mainnet"
  • "testnet"

Contributing

Contributions are welcome! If you find any bugs or have suggestions for improvements, please open an issue or submit a pull request.

License

This project is licensed under the GNU General Public License. See the LICENSE file for more details.

Disclaimer

This library is provided as-is and without any warranty. Use it at your own risk. Always double-check the validity of addresses before transferring funds.

It is in no way validating the existance of an address, only the formatting is being validated here.

/chain-address-validation/

    Package Sidebar

    Install

    npm i chain-address-validation

    Weekly Downloads

    3

    Version

    0.4.0

    License

    LICENSE

    Unpacked Size

    47 kB

    Total Files

    23

    Last publish

    Collaborators

    • nickjpanella