kilvn/geth-jsonrpc-php-client

用于与 geth (go-ethereum) 节点通信的 API 客户端库。

4.0.2 2020-09-29 06:12 UTC

This package is auto-updated.

Last update: 2024-09-29 06:02:58 UTC


README

Downloads this Month Latest Stable Version Build Status Scrutinizer Code Quality Coverage Status

简介

此 API 客户端库用于与 geth (go-ethereum) 节点通信。

最后更新:2018年01月04日(与最新 geth-1.7.3-4bb3c89d 版本完全兼容)。

通过此客户端库,您可以轻松地在节点上运行以下操作:

  • 获取账户余额,
  • 签名交易,
  • 部署交易,
  • ...

所有可在 geth 节点上运行的方法的完整文档描述如下: https://github.com/ethereum/wiki/wiki/JSON-RPC#json-rpc-methods

分支

将 guzzlehttp/guzzle 更新到 ^7.0 以兼容 laravel8

安装

composer require kilvn/geth-jsonrpc-php-client

用法

// Create HTTP client instance (you can use something simplier just wrap it by using IHttpClient interface)
// Create JsonRpc client which can run any operation on your geth node
$httpClient = new GuzzleClient(new GuzzleClientFactory(), 'localhost', 8545);
$client = new Client($httpClient);

// Run operation (all are described here: https://github.com/ethereum/wiki/wiki/JSON-RPC#json-rpc-methods)
$result = $client->callMethod('eth_getBalance', ['0xf99ce9c17d0b4f5dfcf663b16c95b96fd47fc8ba', 'latest']);

// $result->result ==='0x16345785d8a0000'