dappstatus / geth-php
A PHP wrapper to the geth JSON-RPC API.
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Type:project
Requires
- php: >=7.0
- guzzlehttp/guzzle: ~6.3
Requires (Dev)
- phpunit/phpunit: 6.5.*
This package is auto-updated.
Last update: 2024-05-29 05:20:38 UTC
README
A PHP wrapper to the Geth JSON-RPC
Requirements
- PHP >= 7.0.x
- phpunit >= 6.5.*
- cURL Extension
- illuminate/support >= 5.1.*
Installation
composer require dappstatus/geth-php
Usage
$geth = new \dappstatus\Geth\JsonRpc([ // Geth JSON-RPC version 'version' => '2.0', // Host part of address 'host' => '127.0.0.1', // Port part of address 'port' => 8545, // Return results as associative arrays instead of objects 'assoc' => true, ]); $version = $geth->web3_getVersion(); $accounts = $geth->eth_accounts(); foreach($accounts as $account) { echo $account, ': ', $geth->eth_getBalance($account, 'latest'), PHP_EOL; }
Laravel 5
Add the service provider and facade in your config/app.php
Service Provider
dappstatus\Geth\Laravel5\GethPhpServiceProvider::class,
Facade
'JsonRpc' => dappstatus\Geth\Laravel5\Facades\JsonRpc::class,
Laravel 5 Usage
JsonRpc::setOptions([ // Geth JSON-RPC version 'version' => '2.0', // Host part of address 'host' => '127.0.0.1', // Port part of address 'port' => 8545, // Return results as associative arrays instead of objects 'assoc' => true, ]); $version = JsonRpc::web3_getVersion(); $accounts = JsonRpc::eth_accounts(); foreach($accounts as $account) { echo $account, ': ', JsonRpc::eth_getBalance($account, 'latest'), PHP_EOL; } ```"# geth-php" "# geth-php"