-
-
Notifications
You must be signed in to change notification settings - Fork 0
FAQ
Common questions and answers about validator0x.
validator0x is a lightweight, zero-dependency TypeScript library for validating blockchain wallet addresses. It supports multiple blockchains including Ethereum, Polygon, Solana, and Bitcoin.
- Zero dependencies: No bloat, just pure validation logic
- Multi-chain support: One library for multiple blockchains
- TypeScript-first: Full type safety and IntelliSense
- Lightweight: Minimal bundle size impact
- Active maintenance: Built by Web3 developers for Web3 developers
Currently supported:
- Ethereum (Mainnet & Testnet)
- Polygon (Mainnet & Testnet)
- Solana (Mainnet & Devnet)
- Bitcoin (Mainnet & Testnet)
More chains coming soon! Check our roadmap.
npm install validator0xYes! While built with TypeScript, validator0x works perfectly in JavaScript projects:
const { validateAddress } = require('validator0x');
const result = validateAddress('0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb', 'ethereum');
console.log(result.valid);Yes! validator0x is compatible with all modern browsers. It's commonly used in:
- React/Vue/Angular apps
- Browser extensions
- Web3 dApps
Absolutely! Use it in:
- Express/Fastify APIs
- Next.js API routes
- Serverless functions
- CLI tools
Non-strict mode (default):
- Checks basic format and structure
- Accepts addresses with incorrect checksums
- More permissive
Strict mode:
- Enforces EIP-55 checksum for Ethereum/Polygon
- Rejects addresses with wrong casing
- Recommended for production
// Non-strict (default)
validateAddress('0x742d35cc...', 'ethereum'); // Valid
// Strict
validateAddress('0x742d35cc...', 'ethereum', { strict: true }); // Invalid (wrong checksum)Use the network option:
const result = validateAddress(
'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx',
'bitcoin',
{ network: 'testnet' }
);Yes, use detectBlockchain():
const chains = detectBlockchain('0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb');
// Returns: ['ethereum', 'polygon']Note: Some addresses are valid on multiple chains (e.g., Ethereum and Polygon use the same format).
No, validator0x only validates raw addresses. ENS names must be resolved to addresses first using libraries like ethers.js or web3.js.
const formatted = formatAddress(
'0x742d35cc6634c0532925a3b844bc9e7595f0beb',
'ethereum',
{ checksum: true }
);
// Returns: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'const shortened = formatAddress(
'0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
'ethereum',
{ shorten: true, shortenLength: 6 }
);
// Returns: '0x742d35...5f0bEb'Yes! All validations are synchronous and highly optimized. Typical validation takes < 1ms.
Yes, just map over your address array:
const addresses = ['0x...', '0x...', '0x...'];
const results = addresses.map(addr =>
validateAddress(addr, 'ethereum')
);No! All validation happens locally using cryptographic algorithms. No API calls, no internet required.
Types are included automatically:
import {
validateAddress,
ValidationResult,
BlockchainType,
ValidationOptions
} from 'validator0x';
const blockchain: BlockchainType = 'ethereum';
const result: ValidationResult = validateAddress(address, blockchain);TypeScript 4.0 or higher is recommended, but it works with older versions too.
Common reasons:
- Wrong blockchain: Make sure you're validating against the correct chain
-
Incorrect checksum in strict mode: Use
{ strict: false }or fix the checksum - Extra spaces: Trim the address string first
- Wrong format: Bitcoin has multiple formats (legacy, SegWit, etc.)
// Debug validation
const result = validateAddress(address, blockchain);
console.log(result);
// Check result.error and result.details.errorCode for specific issuesSee the ValidationError enum in the API Reference:
-
INVALID_FORMAT: Wrong structure -
INVALID_CHECKSUM: Checksum mismatch -
INVALID_LENGTH: Too short/long -
INVALID_CHARACTERS: Contains invalid characters -
UNSUPPORTED_CHAIN: Blockchain not supported -
BURN_ADDRESS: Zero/burn address -
UNSAFE_INPUT: Potential security issue
validator0x detects common burn addresses (like 0x0000...0000):
const result = validateAddress('0x0000000000000000000000000000000000000000', 'ethereum');
// result.valid = false
// result.details.errorCode = 'BURN_ADDRESS'Yes! validator0x:
- Has zero dependencies (no supply chain attacks)
- Uses battle-tested validation algorithms
- Includes input sanitization
- Is regularly updated
Yes, it includes checks for:
- Overly long inputs
- Special characters
- Injection attempts
Yes, always!
- Frontend validation improves UX
- Backend validation ensures security
Never trust client-side validation alone.
Open an issue with the blockchain name and documentation links.
Please open an issue with:
- The address being validated
- The blockchain type
- Expected vs actual behavior
- Your environment (Node version, browser, etc.)
Absolutely! Check our Contributing Guide for details.
- β Star the GitHub repository
- π Report bugs and suggest features
- π» Contribute code
- β Buy me a coffee
- π° Donate crypto:
0xEe4055Dd5E4896aC50f308eE7846037490482F1f
function validateWalletConnection(address: string, expectedChain: BlockchainType) {
const result = validateAddress(address, expectedChain, { strict: true });
if (!result.valid) {
throw new Error(`Invalid wallet address: ${result.error}`);
}
return true;
}See our React examples for complete form validation patterns.
See our production use cases for batch validation examples.
- π Read the API Reference
- π‘ Check out Examples
- π Open an issue
- π¬ Start a discussion