1.0.6 • Published 5 months ago

@wallaby-cash/address-validator v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

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

  1. 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).
  2. isEvmAddress(address: string): boolean Validates an EVM address.

    • address: The Ethereum address to validate.
  3. isBtcAddress(address: string): boolean Validates a Bitcoin address.

    • address: The Bitcoin address to validate.
  4. isAlgoAddress(address: string): boolean Validates an Algorand address.

    • address: The Algorand address to validate.
1.0.6

5 months ago

1.0.5

5 months ago

1.0.2

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.1

8 months ago

1.0.0

9 months ago