kemalevren / geth-php
A PHP wrapper to the geth JSON-RPC API.
Installs: 360
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 4
Open Issues: 2
Type:project
Requires
- php: >=7.0
- guzzlehttp/guzzle: ~6.3
- illuminate/support: 5.0.*|5.1.*|5.2.*|5.3.*|5.4.*|5.5.*|5.6.*|5.8.*
Requires (Dev)
- phpunit/phpunit: 6.5.*
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 kemalevren/geth-php
Usage
$geth = new \kemalevren\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
kemalevren\Geth\Laravel5\GethPhpServiceProvider::class,
Facade
'JsonRpc' => kemalevren\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; }