dev-master
9999999-devPHP library for the Toshi Bitcoin API
MIT
The Requires
The Development Requires
by Gareth Davies
bitcoin
PHP library for the Toshi Bitcoin API
This library provides a simple PHP interface to the Toshi Bitcoin API., (*2)
The recommended way to install the library is through Composer., (*3)
# Install Composer curl -sS https://getcomposer.org/installer | php # Add Chain-PHP as a dependency php composer.phar require cbix/toshi-php:dev-master
After installing, you need to require Composer's autoloader:, (*4)
require 'vendor/autoload.php';
$toshi = Toshi::make();
The get_block and get_block_transactions methods accept either a block height or block hash, (*5)
$latest_blocks = $toshi->get_latest_blocks(); $latest_block = $toshi->get_latest_block(); $block = $toshi->get_block('00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048'); $block_transactions = $toshi->get_block_transactions('00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048');
$transaction = $toshi->get_transaction('0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098'); $relay_transaction = $toshi->relay_transaction('0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098); $unconfirmed_transactions = $toshi->unconfirmed_transactions('0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098');
$address_balance = $toshi->get_address_balance('12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX'); $address_transactions = $toshi->get_address_transactions('12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX'); $address_unspent_outputs = $toshi->get_address_unspent_outputs('12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX');
If there are any issues during the API request a ToshiException will be thrown which can be caught and managed according to your application needs., (*6)
try { $latest_block = $toshi->get_latest_block(); echo $latest_block->height; } catch (ToshiException $e) { //There was an error more information in $e->getMessage(); var_dump($e->getMessage()); }
This library uses PHPUnit for unit testing. In order to run the unit tests, you'll first need
to install the dependencies of the project using Composer: php composer.phar install --dev
.
You can then run the tests using vendor/bin/phpunit
. The library comes with a set of mocked responses
from the Toshi API for running the unit tests., (*7)
Patches, bug fixes, feature requests, and pull requests are welcome on the GitHub page for this project., (*8)
PHP library for the Toshi Bitcoin API
MIT
bitcoin