2017 © Pedro Peláez
 

library azart-rpc-php

Azart JSON-RPC client based on GuzzleHttp

image

azartpay/azart-rpc-php

Azart JSON-RPC client based on GuzzleHttp

  • Tuesday, June 5, 2018
  • by azartpay
  • Repository
  • 0 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 33 Forks
  • 0 Open issues
  • 22 Versions
  • 0 % Grown

The README.md

Azart RPC PHP

Simple Azart JSON-RPC client based on GuzzleHttp, (*1)

Installation

Run php composer.phar require azartpay/azart-rpc-php in your project directory or add following lines to composer.json, (*2)

"require": {
    "azartpay/azart-rpc-php": "2.0.3"
}

and run php composer.phar update., (*3)

Requirements

PHP 7.0 or higher (should also work on 5.6, but this is unsupported), (*4)

Usage

Create new object with url as parameter, (*5)

use AzartPay\Azart\Client as AzartClient;

$azartd = new AzartClient('http://rpcuser:rpcpassword@localhost:9798/');

or use array to define your azartd settings, (*6)

use AzartPay\Azart\Client as AzartClient;

$azartd = new AzartClient([
    'scheme' => 'http',                 // optional, default http
    'host'   => 'localhost',            // optional, default localhost
    'port'   => 9798,                   // optional, default 9798
    'user'   => 'rpcuser',              // required
    'pass'   => 'rpcpassword',          // required
    'ca'     => '/etc/ssl/ca-cert.pem'  // optional, for use with https scheme
]);

Then call methods defined in Dash Core API Documentation with magic:, (*7)

/**
 * Get block info.
 */
$block = $azartd->getBlock('000009b9903dae4466d48db6c264d711ac554492da34cd0bfa4c0b6d230f29c9');

$block('hash')->get();     // 000009b9903dae4466d48db6c264d711ac554492da34cd0bfa4c0b6d230f29c9
$block['height'];          // 0 (array access)
$block->get('tx.0');       // 44701bbc011bdd471b75fa83e42acc8e067759a69cdeef723df57181a33e5467
$block->count('tx');       // 1
$block->has('version');    // key must exist and CAN NOT be null
$block->exists('version'); // key must exist and CAN be null
$block->contains(0);       // check if response contains value
$block->values();          // array of values
$block->keys();            // array of keys
$block->random(1, 'tx');   // random block txid
$block('tx')->random(2);   // two random block txid's
$block('tx')->first();     // txid of first transaction
$block('tx')->last();      // txid of last transaction

/**
 * Send transaction.
 */
$result = $azartd->sendToAddress('AqUM31KtkxgbMwYrrpUi6RVjaftK3Mv5mG', 0.1);
$txid = $result->get();

/**
 * Get transaction amount.
 */
$result = $azartd->listSinceBlock();
$totalAmount = $result->sum('transactions.*.amount');
$totalSatoshi = AzartClient::toSatoshi($totalAmount);

To send asynchronous request, add Async to method name:, (*8)

use AzartPay\Azart\AzartdResponse;

$promise = $azartd->getBlockAsync(
    '000009b9903dae4466d48db6c264d711ac554492da34cd0bfa4c0b6d230f29c9',
    function (AzartdResponse $success) {
        //
    },
    function (\Exception $exception) {
        //
    }
);

$promise->wait();

You can also send requests using request method:, (*9)

/**
 * Get block info.
 */
$block = $azartd->request('getBlock', '000009b9903dae4466d48db6c264d711ac554492da34cd0bfa4c0b6d230f29c9');

$block('hash');            // 000009b9903dae4466d48db6c264d711ac554492da34cd0bfa4c0b6d230f29c9
$block['height'];          // 0 (array access)
$block->get('tx.0');       // 44701bbc011bdd471b75fa83e42acc8e067759a69cdeef723df57181a33e5467
$block->count('tx');       // 1
$block->has('version');    // key must exist and CAN NOT be null
$block->exists('version'); // key must exist and CAN be null
$block->contains(0);       // check if response contains value
$block->values();          // get response values
$block->keys();            // get response keys
$block->first('tx');       // get txid of the first transaction
$block->last('tx');        // get txid of the last transaction
$block->random(1, 'tx');   // get random txid

/**
 * Send transaction.
 */
$result = $azartd->request('sendtoaddress', ['AqUM31KtkxgbMwYrrpUi6RVjaftK3Mv5mG', 0.06]);
$txid = $result->get();

or requestAsync method for asynchronous calls:, (*10)

use AzartPay\Azart\AzartdResponse;

$promise = $azartd->requestAsync(
    'getBlock',
    '000009b9903dae4466d48db6c264d711ac554492da34cd0bfa4c0b6d230f29c9',
    function (AzartdResponse $success) {
        //
    },
    function (\Exception $exception) {
        //
    }
);

$promise->wait();

License

This product is distributed under MIT license., (*11)

The Versions

05/06 2018

dev-master

9999999-dev https://github.com/azartpay/azart-rpc-php

Azart JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle jsonrpc azart

05/06 2018

2.0.3

2.0.3.0 https://github.com/azartpay/azart-rpc-php

Azart JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle jsonrpc azart

10/04 2018

2.x-dev

2.9999999.9999999.9999999-dev https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

06/04 2018

v2.0.2

2.0.2.0 https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

06/04 2018

dev-analysis-zd21KL

dev-analysis-zd21KL https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

21/08 2017

v2.0.1

2.0.1.0 https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

17/08 2017

v2.0.0

2.0.0.0 https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

17/08 2017

v2.0.0rc1

2.0.0.0-RC1 https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

15/08 2017

v2.0.0beta1

2.0.0.0-beta1 https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

15/08 2017

dev-analysis-z4yy6N

dev-analysis-z4yy6N https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

14/08 2017

dev-analysis-zO2AyJ

dev-analysis-zO2AyJ https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

13/08 2017

1.x-dev

1.9999999.9999999.9999999-dev https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

12/08 2017

v1.0.8

1.0.8.0 https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

12/08 2017

dev-analysis-XaNJgm

dev-analysis-XaNJgm https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

12/08 2017

v1.0.7

1.0.7.0 https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

05/02 2017

v1.0.6

1.0.6.0 https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

31/01 2017

v1.0.5

1.0.5.0 https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

21/01 2017

v1.0.4

1.0.4.0 https://github.com/denpamusic/php-bitcoinrpc

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

21/01 2017

v1.0.3

1.0.3.0 https://github.com/denpamusic/php-bitapi

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

21/01 2017

v1.0.2

1.0.2.0 https://github.com/denpamusic/php-bitapi

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

20/01 2017

v1.0.1

1.0.1.0 https://github.com/denpamusic/php-bitapi

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc

20/01 2017

v1.0.0

1.0.0.0 https://github.com/denpamusic/php-bitapi

Bitcoin JSON-RPC client based on GuzzleHttp

  Sources   Download

MIT

The Requires

 

The Development Requires

by Denis Paavilainen

api guzzle bitcoin jsonrpc