crypto-address-validators
Version:
Wallet address validator for BTC, TRX, ETH, USDT (ERC20, TRC20), HOGE, SFM, SMARS
56 lines (36 loc) • 1.44 kB
Markdown
# crypto-address-validators
Wallet address validator for validating Bitcoin and other altcoins addresses in **Node.js and browser**.
## Installation
```sh
yarn crypto-address-validators
or
npm install crypto-address-validators
```
## API
##### validate (address [, currency = 'bitcoin'[, networkType = 'prod']])
###### Parameters
* address - Wallet address to validate.
* currency - Optional. Currency name or symbol, e.g. `'bitcoin'` (default)
* networkType - Optional. Use `'prod'` (default) to enforce standard address, `'testnet'` to enforce testnet address and `'both'` to enforce nothing.
> Returns true if the address (string) is a valid wallet address for the crypto currency specified, see below for supported currencies.
### Supported crypto currencies
* Bitcoin/BTC, `'bitcoin'` or `'BTC'`
* Ethereum/ETH, `'ethereum'` or `'ETH'`
* Tether/USDT (ERC20), `'usdt'` or `'USDT'` & networkType `'ERC20'`
* Tether/USDT (TRC20), `'usdt'` or `'USDT'` & networkType `'TRC20'`
* Hoge finance/HOGE, `'hoge'` or `'HOGE'`
* Safemoon/SFM, `'sfm'` or `'SFM'`
* Safemars/SMARS, `'smars'` or `'SMARS'`
### Usage example
#### TS
```javascript
import validate from "crypto-address-validators";
const valid = 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.
```