turtlecoin/turtlecoin-rpc-php

此包已被弃用且不再维护。未建议替换包。

TurtleCoin RPC 的 PHP 封装器

v2.1.1 2018-10-29 16:59 UTC

This package is auto-updated.

Last update: 2023-05-29 01:23:22 UTC


README

TurtleCoin RPC PHP 是 TurtleCoin JSON-RPC 接口的 PHP 封装器。

需要 TurtleCoin v0.8.4+

  1. 安装 TurtleCoin RPC PHP
  2. 示例
  3. 文档
  4. 许可

安装 TurtleCoin RPC PHP

此包需要 PHP >=7.1.3。使用 composer 需要此包

composer require turtlecoin/turtlecoin-rpc-php

示例

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]}

可选地,您可以访问关于响应的详细信息

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

文档

TurtleCoin RPC API 的文档以及此包的更多 PHP 示例可以在 api-docs.turtlecoin.lol 找到。

许可

TurtleCoin RPC PHP 是开源软件,许可协议为 MIT 许可协议