raphaelcangucu/laravel-crypto-address-validator
Composer 安装命令:
composer require raphaelcangucu/laravel-crypto-address-validator
包简介
Laravel package for validating cryptocurrency wallet addresses across multiple coins
关键字:
README 文档
README
A Laravel package for validating cryptocurrency wallet addresses across multiple blockchains. Built on top of the multicoin-address-validator library.
Features
- 25+ Cryptocurrencies Supported: Bitcoin, Ethereum, Cardano, Solana, XRP, Litecoin, Bitcoin Cash, and many more
- Network Support: Mainnet, testnet, and stagenet validation
- Laravel Integration: Service provider, facade, and dependency injection support
- Flexible Configuration: Customizable validation rules and options
- High Performance: Optimized for speed and accuracy
- Comprehensive Testing: 100% test coverage with extensive test suite
Supported Cryptocurrencies
Bitcoin (BTC), Ethereum (ETH), Cardano (ADA), Solana (SOL), XRP, Litecoin (LTC), Bitcoin Cash (BCH), Monero (XMR), TRON (TRX), Polkadot (DOT), Dogecoin (DOGE), Chainlink (LINK), Polygon (MATIC), Avalanche (AVAX), Cosmos (ATOM), Tezos (XTZ), VeChain (VET), Algorand (ALGO), Hedera (HBAR), NEAR Protocol (NEAR), Filecoin (FIL), The Graph (GRT), Stellar (XLM), EOS, IOTA, and all ERC-20 tokens.
Installation
You can install the package via composer:
composer require raphaelcangucu/laravel-crypto-address-validator
The package will automatically register its service provider.
You can publish the config file with:
php artisan vendor:publish --tag="crypto-address-validator-config"
This is the contents of the published config file:
<?php // config for CryptoAddressValidator return [ /* |-------------------------------------------------------------------------- | Default Currency |-------------------------------------------------------------------------- | | The default currency to use when validating addresses if no currency | is specified. This can be either a currency symbol (e.g., 'btc') or | the full currency name (e.g., 'bitcoin'). | */ 'default_currency' => 'btc', /* |-------------------------------------------------------------------------- | Default Network Type |-------------------------------------------------------------------------- | | The default network type to use for validation. Options include: | 'prod' (mainnet), 'testnet', 'stagenet' (for supported currencies) | */ 'default_network_type' => 'prod', /* |-------------------------------------------------------------------------- | Strict Mode |-------------------------------------------------------------------------- | | When enabled, strict mode will enforce additional validation rules | such as EIP-55 checksum validation for Ethereum addresses. | When disabled, the validator is more permissive. | */ 'strict_mode' => false, ];
Usage
Facade Usage
use CryptoAddressValidator\Facades\CryptoAddressValidator; // Validate a Bitcoin address $isValid = CryptoAddressValidator::validate('1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2', 'btc'); // Returns: true // Validate an Ethereum address $isValid = CryptoAddressValidator::validate('0x742d35Cc6339C4532CE58b5D3Ea8d5A8d6F6395C', 'eth'); // Returns: true // Validate with options $isValid = CryptoAddressValidator::validate( 'tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx', 'btc', ['networkType' => 'testnet'] ); // Returns: true // Get all supported currencies $currencies = CryptoAddressValidator::getCurrencies(); // Find a specific currency $currency = CryptoAddressValidator::findCurrency('btc'); // Returns: ['symbol' => 'btc', 'name' => 'Bitcoin', ...] // Check if a currency is supported $isSupported = CryptoAddressValidator::isSupported('btc'); // Returns: true
Dependency Injection
use CryptoAddressValidator\CryptoAddressValidator; class PaymentController extends Controller { public function validateAddress(CryptoAddressValidator $validator, Request $request) { $address = $request->input('address'); $currency = $request->input('currency'); if ($validator->validate($address, $currency)) { return response()->json(['valid' => true]); } return response()->json(['valid' => false, 'message' => 'Invalid address']); } }
Validation in Form Requests
use CryptoAddressValidator\Facades\CryptoAddressValidator; use Illuminate\Foundation\Http\FormRequest; class PaymentRequest extends FormRequest { public function rules() { return [ 'address' => [ 'required', 'string', function ($attribute, $value, $fail) { if (!CryptoAddressValidator::validate($value, $this->currency)) { $fail('The '.$attribute.' is not a valid cryptocurrency address.'); } }, ], 'currency' => 'required|string', ]; } }
Custom Validation Rule
You can create a custom validation rule:
use CryptoAddressValidator\Facades\CryptoAddressValidator; use Illuminate\Contracts\Validation\Rule; class CryptoAddress implements Rule { protected $currency; protected $options; public function __construct($currency, $options = []) { $this->currency = $currency; $this->options = $options; } public function passes($attribute, $value) { return CryptoAddressValidator::validate($value, $this->currency, $this->options); } public function message() { return 'The :attribute must be a valid ' . strtoupper($this->currency) . ' address.'; } }
Usage:
$request->validate([ 'btc_address' => ['required', new CryptoAddress('btc')], 'eth_address' => ['required', new CryptoAddress('eth')], 'testnet_address' => ['required', new CryptoAddress('btc', ['networkType' => 'testnet'])], ]);
Advanced Usage
Validation Options
// Validate with specific network CryptoAddressValidator::validate($address, 'btc', [ 'networkType' => 'testnet' // 'prod', 'testnet', 'stagenet' ]); // Ethereum with strict checksum validation CryptoAddressValidator::validate($address, 'eth', [ 'validateChecksum' => true ]); // Custom validation options CryptoAddressValidator::validate($address, 'xrp', [ 'validateTag' => true ]);
Getting Currency Information
// Get all supported currencies $currencies = CryptoAddressValidator::getCurrencies(); /* Returns array like: [ [ 'symbol' => 'btc', 'name' => 'Bitcoin', 'networkTypes' => ['prod', 'testnet'] ], // ... more currencies ] */ // Find specific currency $bitcoin = CryptoAddressValidator::findCurrency('bitcoin'); $ethereum = CryptoAddressValidator::findCurrency('eth'); // Check support $isSupported = CryptoAddressValidator::isSupported('btc'); // true $isSupported = CryptoAddressValidator::isSupported('unknown'); // false
Access Underlying Validator
// Get the underlying multicoin validator instance $validator = CryptoAddressValidator::getValidator(); // Use advanced features directly $result = $validator->validateWithDetails($address, $currency);
Testing
composer test
Performance
The package is optimized for high performance:
- Fast validation: Uses native cryptocurrency validation algorithms
- No external dependencies: All validation is done locally
- Minimal dependencies: Built on a lightweight foundation
- Memory efficient: Low memory footprint even with large validation sets
Error Handling
The package handles errors gracefully:
try { $isValid = CryptoAddressValidator::validate($address, $currency); } catch (\Exception $e) { // Handle validation errors Log::error('Address validation failed: ' . $e->getMessage()); $isValid = false; }
Security
- Input validation: All inputs are properly validated and sanitized
- No external API calls: All validation is done locally for security and performance
- Safe error handling: Errors don't expose sensitive information
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
raphaelcangucu/laravel-crypto-address-validator 适用场景与选型建议
raphaelcangucu/laravel-crypto-address-validator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.01k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 06 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「address」 「validation」 「crypto」 「laravel」 「bitcoin」 「wallet」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 raphaelcangucu/laravel-crypto-address-validator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 raphaelcangucu/laravel-crypto-address-validator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 raphaelcangucu/laravel-crypto-address-validator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Maps in minutes. Powered by the Google Maps API.
Redirects TYPO3 visitors automatic or with a suggestlink to another language and/or root page.
Module adding custom shipping attribute for what3words address
High-level cryptographic primitives and security utilities for Maatify systems including password hashing, reversible encryption, HKDF key derivation, and key rotation.
Adds request-parameter validation to the SLIM 3.x PHP framework
A jQuery augmented PHP library for creating and validating HTML forms
统计信息
- 总下载量: 21.01k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 32
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-25