Multi-cryptocurrency RPC integration for Laravel with dedicated facades
skaisser/laravel-multicoin-rpc is a Laravel package for multi-cryptocurrency rpc integration for laravel with dedicated facades.
It currently has 0 GitHub stars and 2 downloads on Packagist (latest version v1.0.2).
Install it with composer require skaisser/laravel-multicoin-rpc.
Discover more Laravel packages by skaisser
or browse all Laravel packages to compare alternatives.
Last updated
Multi-cryptocurrency RPC integration for Laravel with dedicated facades for each coin. Production-ready with circuit breakers, health monitoring, and automatic failover.
Bitcoin::, Bch::, Ltc::, Bc2:: instead of complex factoriescomposer require skaisser/laravel-multicoin-rpc
Add to your .env file:
# Bitcoin only
BITCOIN_RPC_HOST=localhost
BITCOIN_RPC_PORT=8332
BITCOIN_RPC_USER=your-rpc-user
BITCOIN_RPC_PASSWORD=your-rpc-password
Use in your code:
use Bitcoin;
// Get blockchain info
$info = Bitcoin::getBlockchainInfo();
// Get current block count
$height = Bitcoin::getBlockCount();
// Get specific block
$block = Bitcoin::getBlock($blockHash);
// Validate address
$valid = Bitcoin::validateAddress('bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh');
Add primary and backup nodes to .env:
# Primary node
BITCOIN_RPC_HOST=localhost
BITCOIN_RPC_PORT=8332
BITCOIN_RPC_USER=your-rpc-user
BITCOIN_RPC_PASSWORD=your-rpc-password
# Backup node (automatic failover)
BITCOIN_RPC_BACKUP_HOST=backup.server.com
BITCOIN_RPC_BACKUP_PORT=8332
BITCOIN_RPC_BACKUP_USER=backup-user
BITCOIN_RPC_BACKUP_PASSWORD=backup-password
The package automatically switches to the backup node if the primary fails.
use Bitcoin;
use Bch;
use Ltc;
use Bc2;
// Each coin has its own facade
$btcInfo = Bitcoin::getBlockchainInfo();
$bchInfo = Bch::getBlockchainInfo();
$ltcInfo = Ltc::getBlockchainInfo();
$bc2Info = Bc2::getBlockchainInfo();
For detailed configuration options, see Installation Guide.
All coins support these common RPC methods:
// Blockchain
getBlockchainInfo()
getBlockCount()
getBlock(string $hash, int $verbosity = 1)
getBlockHash(int $height)
// Transactions
getRawTransaction(string $txid, bool $verbose = false)
sendRawTransaction(string $hexString)
validateAddress(string $address)
// Network
getNetworkInfo()
getPeerInfo()
getConnectionCount()
// Mining
getMiningInfo()
getDifficulty()
# Check node health
php artisan multicoin:health
# List configured coins
php artisan multicoin:list
# Add new coin support
php artisan multicoin:add dash --name="Dash" --port=9998
php artisan multicoin:health --coin=btc
# Output:
# Bitcoin (BTC) Health Check
# ==========================
# Primary Node: β
Healthy (245ms)
# Backup Node: β
Healthy (312ms)
# Block Height: 830,000
# Circuit Breaker: Closed
use Skaisser\MultiCoinRpc\Events\NodeFailover;
use Illuminate\Support\Facades\Event;
Event::listen(NodeFailover::class, function ($event) {
Log::warning("Node failover: {$event->coin} switched from {$event->failedNode} to {$event->activeNode}");
});
composer test
composer test-coverage
Mock RPC calls in your tests:
use Bitcoin;
it('can get block count', function () {
Bitcoin::fake(['getBlockCount' => 830000]);
expect(Bitcoin::getBlockCount())->toBe(830000);
});
If you discover any security issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
Made with β€οΈ by Shirleyson Kaisser