A typescript library for validation bitcoin and most of altcoins address.
🏠 Homepage
- node >=8.9
yarn
yarn doc
yarn test
- 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
/**
* 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;
}
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');
}
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');
<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');
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Give a ⭐️ if this project helped you!