multicoin-address-validator README

The project's README from github.com/Nonco-Organization/multicoin-address-validator. As one markdown file: README.md.

wallet-address-validator

Simple wallet address validator for validating Bitcoin and other altcoins addresses in Node.js and browser.

Build Status

Forked from ryanralph/altcoin-address.

File size is ~17 kB (minifed and gzipped).

Installation

NPM

npm install multicoin-address-validator

Browser

<script src="wallet-address-validator.min.js"></script>

API

validate (address [, currency = 'bitcoin'[, networkType = 'prod']])
Parameters

Returns true if the address (string) is a valid wallet address for the crypto currency specified, see below for supported currencies.

Supported crypto currencies

Usage example

Node

var WAValidator = require('multicoin-address-validator');

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

// This will log 'This is a valid address' to the console.
var WAValidator = require('multicoin-address-validator');

var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'litecoin', 'testnet');
if(valid)
      console.log('This is a valid address');
else
      console.log('Address INVALID');

// As this is a invalid litecoin address 'Address INVALID' will be logged to console.
var WAValidator = require('multicoin-address-validator');

var currency = WAValidator.findCurrency('xrp');
if(currency)
      console.log('This currency exists');
else
      console.log('Currency INVALID');

// As this is a valid currency symbol 'This currency exists' will be logged to console.
var WAValidator = require('multicoin-address-validator');

var currency = WAValidator.findCurrency('random');
if(currency)
      console.log('This currency exists');
else
      console.log('Currency INVALID');

// As this is not a valid currency symbol 'Currency INVALID' will be logged to console.

Browser

<script src="wallet-address-validator.min.js"></script>
// WAValidator is exposed as a global (window.WAValidator)
var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'bitcoin');
if(valid)
    alert('This is a valid address');
else
    alert('Address INVALID');

// This should show a pop up with text 'This is a valid address'.

multicoin-address-validator (Nonco-Organization/multicoin-address-validator)

Searching Database…

What is this?A JavaScript library that validates wallet addresses for Bitcoin, Litecoin, Ethereum, and over 100 other cryptocurrencies.
Is it a framework or a library?It is a lightweight library you import into your own code, exposing a single validate function, not a standalone app.
How do I add it to a project?Install it via NPM, or include the browser build directly in a web page.
Do I need any API keys or network access to use it?No, it's a pure validation library that checks address format and checksums locally without calling any blockchain or external service.
Does validation only check format, or does it verify the address actually exists on-chain?It only validates the address format/checksum for the given currency; it does not check whether the address is actually in use or funded on the blockchain.
Is this only for Bitcoin-like coins, or does it work with Ethereum-style addresses too?It supports both Bitcoin-style UTXO coins and Ethereum-style account addresses, plus many ERC-20 tokens that share Ethereum's address format.
How does the validate function work?Call validate(address, currency, networkType) where currency defaults to 'bitcoin' and networkType can be 'prod', 'testnet', or 'both'; it returns true if the address is valid for that coin.
Can I validate testnet addresses?Yes, passing 'testnet' as the networkType parameter enforces testnet address rules instead of production mainnet addresses.
Where did this project come from?It is a fork of ryanralph/altcoin-address, extended to support many more cryptocurrencies.
How many cryptocurrencies are supported?The README lists over 100 supported coins and tokens, identified by either their full name or ticker symbol (e.g. 'bitcoin' or 'btc').
Size
1.6 MB
Stars
230
Updated
CommitApr 29
Age
9d
Commits · 90 Days