1.0.6 • Published 5 months ago
@wallaby-cash/address-validator v1.0.6
Blockchain Address Validator
This package provides utility functions to validate addresses for different blockchains including Algorand, Bitcoin, and Ethereum.
Installation
You can install the package using npm:
npm install @wallaby-cash/address-validator
Usage
Importing the Functions
import { BlockchainName } from 'wallaby-cash';
import { isAddressValid, isEvmAddress, isBtcAddress, isAlgoAddress } from '@wallaby-cash/address-validator';
Validating Addresses
- Validate Address Based on Blockchain Name
const address = 'your-address-here';
const chainName = BlockchainName.Bitcoin; // or BlockchainName.Algorand, BlockchainName.Ethereum
const isValid = isAddressValid(address, chainName);
console.log(`Is address valid: ${isValid}`);
- Validate EVM Address
const evmAddress = '0x123...';
const isValidEvm = isEvmAddress(evmAddress);
console.log(`Is Ethereum address valid: ${isValidEvm}`);
- Validate Bitcoin Address
const btcAddress = '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa';
const isValidBtc = isBtcAddress(btcAddress);
console.log(`Is Bitcoin address valid: ${isValidBtc}`);
- Validate Algorand Address
const algoAddress = 'VALID_ALGO_ADDRESS';
const isValidAlgo = isAlgoAddress(algoAddress);
console.log(`Is Algorand address valid: ${isValidAlgo}`);
Functions
isAddressValid(address: string, chainName: BlockchainName): boolean
Validates the address based on the blockchain name.address
: The address to validate.chainName
: The blockchain name (BlockchainName.Algorand, BlockchainName.Bitcoin, BlockchainName.Ethereum).
isEvmAddress(address: string): boolean
Validates an EVM address.address
: The Ethereum address to validate.
isBtcAddress(address: string): boolean
Validates a Bitcoin address.address
: The Bitcoin address to validate.
isAlgoAddress(address: string): boolean
Validates an Algorand address.address
: The Algorand address to validate.