cryptocurrency-address-checker
TypeScript icon, indicating that this package has built-in type declarations

0.1.18 • Public • Published

Welcome to cryptocurrency-address-checker 👋

Version Documentation Maintenance License: MIT circleci

A typescript library for validation bitcoin and most of altcoins address.

🏠 Homepage

Prerequisites

  • node >=8.9

Install

yarn

Usage

yarn doc

Run tests

yarn test

Supported crypto currencies

  • Bitcoin/BTC
  • Bitcoin Cash/BCH
  • Ethereum/ETH
  • Litecoin/LTC
  • Ripple/XRP
  • Stellar Lumens/XLM
  • Cardano/ADA
  • Tron/TRX
  • Monero/XMR
  • IOTA
  • Dash/DASH
  • Cosmos/ATOM
  • NEO
  • Dogecoin/DOGE
  • Zcash/ZEC
  • NEM/XEM
  • V Systems/VSYS
  • Decred/DCR
  • Qtum/QTUM
  • Nano/NANO
  • Bytom/BTM

API

/**
 * Checks if the given string is an address
 *
 * @param {string} address
 * @param {string} coin
 * @returns {boolean}
 */
function isValid(address: string, coin: string): boolean;

/**
 * Use regex to pre-check the address is a legal address type.
 *
 * @param {string} address
 * @param {string} coin
 * @returns {boolean}
 */
function preCheck(address: string, coin: string): boolean;

/**
 * Get the checker
 *
 * @param {string} coin
 * @returns {IChecker}
 */
function cryptoChecker(coin: string): IChecker;

interface IChecker {
  isValid(address: string): boolean;
  preCheck(address: string): boolean;
}

Examples

Typescript

import { isValid } from 'cryptocurrency-address-checker';

const valid: boolean = isValid('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'BTC');
if (valid) {
  console.log('This is a valid address');
} else {
  console.log('Address INVALID');
}

Javascript

import { isValid, preCheck } from 'cryptocurrency-address-checker';

var valid = isValid('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'BTC');
if (valid) console.log('This is a valid BTC address');
else console.log('BTC Address INVALID');

var valid = preCheck('Xx4dYKgz3Zcv6kheaqog3fynaKWjbahb6b', 'dash');
if (valid) console.log('This is a valid DASH address');
else console.log('DASH Address INVALID');

Browser

<script src="cryptocurrency-address-checker.min.js"></script>
// CAChecker is exposed as a global (window.CAChecker)
var valid = CAChecker.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'bitcoin');
if (valid) console.log('This is a valid address');
else console.log('Address INVALID');

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2019 jxiaox.
This project is MIT licensed.

Readme

Keywords

none

Package Sidebar

Install

npm i cryptocurrency-address-checker

Weekly Downloads

3

Version

0.1.18

License

MIT

Unpacked Size

1.01 MB

Total Files

151

Last publish

Collaborators

  • jxiaox