PHP code example of lajosbencz / geth-php
1. Go to this page and download the library: Download lajosbencz/geth-php library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lajosbencz / geth-php example snippets
$geth = new \GethApi\GethApi([
// 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;
}
composer