PHP code example of skaisser / laravel-multicoin-rpc

1. Go to this page and download the library: Download skaisser/laravel-multicoin-rpc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

skaisser / laravel-multicoin-rpc example snippets


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');

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();

// 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()

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}");
});

use Bitcoin;

it('can get block count', function () {
    Bitcoin::fake(['getBlockCount' => 830000]);

    expect(Bitcoin::getBlockCount())->toBe(830000);
});
bash
# 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