PHP code example of phramz / php-bitcoin-api

1. Go to this page and download the library: Download phramz/php-bitcoin-api 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/ */

    

phramz / php-bitcoin-api example snippets

 json
"phramz/php-bitcoin-api": "dev-master"
}

php composer.phar 
 php


use Phramz\Bitcoin\Api\Connection\BuzzConnection;
use Phramz\Bitcoin\Api\BitcoindClient;
use Buzz\Browser;

// setup a connection
$connection = new BuzzConnection(new Browser(), '192.168.56.1', '8333', 'username123', 'password123');

// setup the client
$bitcoinClient = new BitcoindClient($connection);

echo "current balance:  " . $bitcoinClient->getBalance() . PHP_EOL;
echo "number of blocks: " . $bitcoinClient->getBlockCount() . PHP_EOL;
 php

echo "transaction id: ". $bitcoinClient->sendToAddress('1JGNmDQVjk7T4S1pcvdDsPJsFuQuZcMDe8', 0.01, 'donation');