turtlecoin/turtlecoin-walletd-rpc-php

此包已被废弃,不再维护。作者建议使用turtlecoin/turtlecoin-rpc-php包。

为TurtleCoin的RPC接口提供的PHP包装器

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

This package is auto-updated.

Last update: 2022-02-01 13:12:35 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 许可协议