Ethereum PHP
PHP interface to Ethereum JSON-RPC API.
list-balance-example.php
Go to the documentation of this file.
1 <?php
2 
6 
7 
11 define('IS_PUBLIC', TRUE);
12 
13 require_once __DIR__ . '/examples.inc.php';
14 
24 
25  try {
26 
27  $eth = new Ethereum('http://127.0.0.1:7545');
28  $balanceInWei = $eth->eth_getBalance(new EthD20($address), new EthBlockParam())->val();
29  return $eth->convertCurrency($balanceInWei);
30 
31  }
32  catch (\Exception $exception) {
33  echo "<p style='color: red;'>We have a problem:<br />";
34  echo $exception->getMessage() . "</p>";
35  echo "<pre>" . $exception->getTraceAsString() . "</pre>";
36  }
37 
38 }
39 
40 
41 $address = '0x78f444392cB2C0aF3cF606De36Ad080EBf22b500';
42 
43 printTable([
44  0 => ['Address', 'Balance in Ether'],
46 ]);
if(!IS_PUBLIC) printTable($rows)
getBalanceAtAddress($address)
Definition: Abi.php:3