TurtleCoin RPC PHP is a PHP wrapper for the TurtleCoin's JSON-RPC interfaces.
Switch branches/tags
Nothing to show
Clone or download
Pull request Compare This branch is even with timmcleod:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/TurtleCoin Fixed daemon getBlockHash() param height is int Oct 29, 2018
tests Added convenience methods to JsonResponse Oct 21, 2018
.gitignore
LICENSE
README.md Updated with v0.8.4 changes Oct 29, 2018
composer.json Added rpcBaseRoute config option. Fixed tests. Etc Oct 20, 2018
composer.lock Added rpcBaseRoute config option. Fixed tests. Etc Oct 20, 2018
phpunit.xml Updated examples in README Oct 21, 2018

README.md

TurtleCoin RPC PHP

TurtleCoin RPC PHP is a PHP wrapper for the TurtleCoin JSON-RPC interfaces.

Requires TurtleCoin v0.8.4+


  1. Install TurtleCoin RPC PHP
  2. Examples
  3. Docs
  4. License

Install TurtleCoin RPC PHP

This package requires PHP >=7.1.3. Require this package with composer:

composer require turtlecoin/turtlecoin-rpc-php

Examples

use TurtleCoin\TurtleCoind;

$config = [
    'rpcHost' => 'http://127.0.0.1',
    'rpcPort' => 11898,
];

$turtlecoind = new TurtleCoind($config);
echo $turtlecoind->getBlockCount();

> {"id":2,"jsonrpc":"2.0","result":{"count":784547,"status":"OK"}}
use TurtleCoin\TurtleService;

$config = [
    'rpcHost'     => 'http://127.0.0.1',
    'rpcPort'     => 8070,
    'rpcPassword' => 'test',
];

$turtleService = new TurtleService($config);
echo $turtleService->getBalance($walletAddress);

> {"id":0,"jsonrpc":"2.0","result":["availableBalance":100,"lockedAmount":50]}

Optionally, you may access details about the response:

$response = $turtleService->getBalance($walletAddress);

// The result field from the RPC response
$response->result();

// RPC response as JSON string
$response->toJson();

// RPC response as an array
$response->toArray();

// Or other response details
$response->getStatusCode();
$response->getProtocolVersion();
$response->getHeaders();
$response->hasHeader($header);
$response->getHeader($header);
$response->getHeaderLine($header);
$response->getBody();

Docs

Documentation of the TurtleCoin RPC API and more PHP examples for this package can be found at api-docs.turtlecoin.lol.

License

TurtleCoin RPC PHP is open-sourced software licensed under the MIT license.