Wallet address validator for Bitcoin and other Altcoins.
npm install @swyftx/api-crypto-address-validatorForked from ognus/wallet-address-validator which was forked from ryanralph/altcoin-address.
Did you know? This package is under active development by Swyftx. Swyftx allows you to buy and sell Bitcoin, Etherium, Ripple and many more assets using Australian Dollars. Buy Bitcoin in Australia
File size is ~189.4 kB (minifed and gzipped - ~69.7% smaller).
#### Yarn
``bash`
yarn add @swyftx/api-crypto-address-validator
#### NPM
`bash`
npm install @swyftx/api-crypto-address-validator
#### Browser
`html`
#### Minified Packed Frontend
`typescript`
import walletAddressValidatorMinJs from '@swyftx/api-crypto-address-validator/dist/wallet-address-validator.min.js'
##### validate (address [, currency = 'bitcoin'[, networkType = 'prod' [, addressType = ['all']]])
###### Parameters
* address - Wallet address to validate.
* currency - Optional. Currency name or symbol, e.g. 'bitcoin' (default), 'litecoin' or 'LTC''prod'
* networkType - Optional. Use (default) to enforce standard address, 'testnet' to enforce testnet address and 'both' to enforce nothing.'legacy'
* addressType - Optional. Specifies what version of the address should be validated. Defaults to , but can be changed on a per asset basis.
> Returns true if the address (string) is a valid wallet address for the crypto currency specified, see below for supported currencies.
* 0x/zrx '0x' or 'zrx''Aave'
* Aave/lend or 'lend''AdEx'
* AdEx/adx or 'adx''aelf'
* aelf/ELF or 'ELF''Aeternity'
* Aeternity/ae or 'ae''Algorand'
* Algorand/algo or 'algo''Aragon'
* Aragon/ant or 'ant''Ardor'
* Ardor/ardr or 'ardr''Augur'
* Augur/rep or 'rep''AuroraCoin'
* AuroraCoin/aur or 'aur''Australian Dollars'
* Australian Dollars/aud or 'aud''Bancor'
* Bancor/bnt or 'bnt''Bankex'
* Bankex/bkx or 'bkx''BasicAttentionToken'
* BasicAttentionToken/bat or 'bat''BeaverCoin'
* BeaverCoin/bvc or 'bvc''BinanceCoin'
* BinanceCoin/bnb or 'bnb''BioCoin'
* BioCoin/bio or 'bio''Bitcoin'
* Bitcoin/btc or 'btc''Bitcoin Diamond'
* Bitcoin Diamond/bcd or 'bcd''BitcoinCash'
* BitcoinCash/bcc or 'bcc''BitcoinCash'
* BitcoinCash/bch or 'bch''BitcoinGold'
* BitcoinGold/btg or 'btg''BitcoinPrivate'
* BitcoinPrivate/btcp or 'btcp''BitcoinZ'
* BitcoinZ/btcz or 'btcz''Bitquence'
* Bitquence/bqx or 'bqx''Bitshares'
* Bitshares/bts or 'bts''BitTorrent'
* BitTorrent/btt or 'btt''Blockstack'
* Blockstack/stx or 'stx''Callisto'
* Callisto/clo or 'clo''Cardano'
* Cardano/ada or 'ada''Chainlink'
* Chainlink/link or 'link''Civic'
* Civic/cvc or 'cvc''Cosmos'
* Cosmos/atom or 'atom''Dash'
* Dash/dash or 'dash''Decentraland'
* Decentraland/MANA or 'MANA''Decred'
* Decred/dcr or 'dcr''Dent'
* Dent/dent or 'dent''DigiByte'
* DigiByte/dgb or 'dgb''District0x'
* District0x/dnt or 'dnt''DogeCoin'
* DogeCoin/doge or 'doge''Enigma'
* Enigma/eng or 'eng''Enjin Coin'
* Enjin Coin/enj or 'enj''EOS'
* EOS/eos or 'eos''Ethereum'
* Ethereum/eth or 'eth''EthereumClassic'
* EthereumClassic/etc or 'etc''EtherZero'
* EtherZero/etz or 'etz''ETHOS'
* ETHOS/ethos or 'ethos''Expanse'
* Expanse/exp or 'exp''FreiCoin'
* FreiCoin/frc or 'frc''FunFair'
* FunFair/fun or 'fun''GameCredits'
* GameCredits/game or 'game''GarliCoin'
* GarliCoin/grlc or 'grlc''Gnosis'
* Gnosis/gno or 'gno''Golem'
* Golem/gnt or 'gnt''Golem'
* Golem/gnt or 'gnt''Hedera Hashgraph'
* Hedera Hashgraph/hbar or 'hbar''Holo'
* Holo/HOT or 'HOT''Horizen'
* Horizen/zen or 'zen''Hush'
* Hush/hush or 'hush''ICON'
* ICON/icx or 'icx''iExec RLC'
* iExec RLC/RLC or 'RLC''iExec RLC'
* iExec RLC/rlc or 'rlc''Internet of Services'
* Internet of Services/IOST or 'IOST''Iota'
* Iota/iota or 'iota''Komodo'
* Komodo/kmd or 'kmd''Lisk'
* Lisk/lsk or 'lsk''LiteCoin'
* LiteCoin/ltc or 'ltc''Matchpool'
* Matchpool/gup or 'gup''MegaCoin'
* MegaCoin/mec or 'mec''Melon'
* Melon/mln or 'mln''Metal'
* Metal/mtl or 'mtl''Monacao'
* Monacao/mco or 'mco''MonaCoin'
* MonaCoin/mona or 'mona''Monero'
* Monero/xmr or 'xmr''NameCoin'
* NameCoin/nmc or 'nmc''Nano'
* Nano/nano or 'nano''NEM'
* NEM/xem or 'xem''Neo'
* Neo/neo or 'neo''NeoGas'
* NeoGas/gas or 'gas''Nexus'
* Nexus/nxs or 'nxs''Numeraire'
* Numeraire/nmr or 'nmr''Odyssey'
* Odyssey/ocn or 'ocn''OmiseGO'
* OmiseGO/omg or 'omg''Ontology'
* Ontology/ont or 'ont''Ontology Gas'
* Ontology Gas/ong or 'ong''Paxos Standard Token'
* Paxos Standard Token/pax or 'pax''PeerCoin'
* PeerCoin/ppc or 'ppc''PIVX'
* PIVX/pivx or 'pivx''Polymath'
* Polymath/poly or 'poly''Populous'
* Populous/ppt or 'ppt''PowerLedger'
* PowerLedger/powr or 'powr''PrimeCoin'
* PrimeCoin/xpm or 'xpm''ProtoShares'
* ProtoShares/pts or 'pts''Pundi X'
* Pundi X/npxs or 'npxs''Qtum'
* Qtum/qtum or 'qtum''RaiBlocks'
* RaiBlocks/xrb or 'xrb''Ravencoin'
* Ravencoin/rvn or 'rvn''RipioCreditNetwork'
* RipioCreditNetwork/rcn or 'rcn''Ripple'
* Ripple/xrp or 'xrp''Salt'
* Salt/salt or 'salt''Siacoin'
* Siacoin/sc or 'sc''SnowGem'
* SnowGem/sng or 'sng''SolarCoin'
* SolarCoin/slr or 'slr''Status'
* Status/snt or 'snt''STEEM'
* STEEM/steem or 'steem''Stellar Lumens'
* Stellar Lumens/xlm or 'xlm''Storj'
* Storj/storj or 'storj''Storm'
* Storm/storm or 'storm''Stratis'
* Stratis/strat or 'strat''Substratum'
* Substratum/sub or 'sub''Swarm City'
* Swarm City/swt or 'swt''Syscoin'
* Syscoin/sys or 'sys''TenX'
* TenX/pay or 'pay''Tether'
* Tether/usdt or 'usdt''Tezos'
* Tezos/XTZ or 'XTZ''THETA'
* THETA/theta or 'theta''Tron'
* Tron/trx or 'trx''TrueUSD'
* TrueUSD/tusd or 'tusd''USD Coin'
* USD Coin/usdc or 'usdc''VeChain'
* VeChain/vet or 'vet''Verge'
* Verge/xvg or 'xvg''VertCoin'
* VertCoin/vtc or 'vtc''Viberate'
* Viberate/vib or 'vib''VoteCoin'
* VoteCoin/vot or 'vot''WaltonChain'
* WaltonChain/wtc or 'wtc''Waves'
* Waves/waves or 'waves''Wings'
* Wings/wings or 'wings''ZCash'
* ZCash/zec or 'zec''ZClassic'
* ZClassic/zcl or 'zcl''ZenCash'
* ZenCash/zen or 'zen''Zilliqa'
* Zilliqa/zil or 'zil'
#### Node
`javascript
const WAValidator = require('@swyftx/api-crypto-address-validator')
const 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.
`
`javascript
const WAValidator = require('@swyftx/api-crypto-address-validator')
const 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.
`
#### Browser
`html`
`javascript
// WAValidator is exposed as a global (window.WAValidator)
const 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'.
``