11 define(
'IS_PUBLIC', TRUE);
13 require_once __DIR__ .
'/examples.inc.php';
20 'http://localhost:7545',
24 'https://kovan.infura.io/drupal' 30 echo
"<h3>What's up on $url</h3>";
36 echo
"<p style='color: red;'>We have a problem:<br />";
37 echo $exception->getMessage() .
"</p>";
38 echo
"<pre>" . $exception->getTraceAsString() .
"</pre>";
55 $rows[] = [
'<b>JsonRPC standard Methods</b>',
'Read more about <a href="https://github.com/ethereum/wiki/wiki/JSON-RPC">Ethereum JsonRPC-API</a> implementation.'];
56 $rows[] = [
"Client version (web3_clientVersion)", $eth->web3_clientVersion()->val()];
57 $rows[] = [
"Listening (net_listening)", $eth->net_listening()->val() ?
'✔' :
'✘'];
58 $rows[] = [
"Peers (net_peerCount)", $eth->net_peerCount()->val()];
59 $rows[] = [
"Protocol version (eth_protocolVersion)", $eth->eth_protocolVersion()->val()];
60 $rows[] = [
"Network version (net_version)", $eth->net_version()->val()];
61 $rows[] = [
"Syncing (eth_syncing)", $eth->eth_syncing()->val() ?
'✔' :
'✘'];
64 $rows[] = [
"Mining (eth_mining)", $eth->eth_mining()->val() ?
'✔' :
'✘'];
66 $hash_rate = $eth->eth_hashrate();
67 $mining = is_a($hash_rate,
'EthQ') ? ((int) ($hash_rate->val() / 1000) .
' KH/s') :
'✘';
68 $rows[] = [
"Mining hashrate (eth_hashrate)", $mining];
71 $price = $eth->eth_gasPrice()->val();
72 $price = $price .
'wei ( ≡ ' . number_format(($price / 1000000000000000000), 8,
'.',
'') .
' Ether)';
73 $rows[] = [
"Current price per gas in wei (eth_gasPrice)", $price];
76 $rows[] = [
"<b>Block info</b>",
''];
77 $block_latest = $eth->eth_getBlockByNumber(
new EthBlockParam(
'latest'),
new EthB(FALSE));
80 date(DATE_RFC850, $block_latest->getProperty(
'timestamp')),
85 $block_earliest = $eth->eth_getBlockByNumber(
new EthBlockParam(1),
new EthB(FALSE));
87 "Age of block number '1' <br/><small>The 'earliest' block has no timestamp on many networks.</small>",
88 $block_earliest->getProperty(
'timestamp'),
91 "Client first (eth_getBlockByNumber('earliest'))",
92 '<div style="max-width: 800px; max-height: 120px; overflow: scroll">' . $eth->debug(
'', $block_earliest) .
'</div>',
96 $block_latest = $eth->eth_getBlockByNumber(
new EthBlockParam(
'earliest'),
new EthB(FALSE));
98 "Client first (eth_getBlockByNumber('latest'))",
99 '<div style="max-width: 800px; max-height: 120px; overflow: scroll">' . $eth->debug(
'', $block_latest) .
'</div>',
102 "Uncles of latest block",
103 '<div style="max-width: 800px; max-height: 120px; overflow: scroll">' . $eth->debug(
'', $block_latest->getProperty(
'uncles')) .
'</div>',
106 $high_block = $eth->eth_getBlockByNumber(
new EthBlockParam(999999999),
new EthB(FALSE));
108 "Get hash of a high block number<br /><small>Might be empty</small>",
109 $high_block->getProperty(
'hash'),
114 $rows[] = [
"<b>Accounts info</b>",
''];
115 $coin_base = $eth->eth_coinbase()->hexVal();
116 if ($coin_base ===
'0x0000000000000000000000000000000000000000') {
117 $coin_base =
'No coinbase available at this network node.';
120 $rows[] = [
"Coinbase (eth_coinbase)", $coin_base];
121 $address = [
'No accounts available.'];
122 $accounts = $eth->eth_accounts();
123 if (count($accounts)) {
125 foreach ($eth->eth_accounts() as $addr) {
129 $rows[] = [
"Accounts (eth_accounts)", implode(
', ',
$address)];
133 "web3_sha3('Hello World')",
135 $eth->sha3(
'Hello World'),
139 $rows[] = [
'<b>Non standard methods</b>',
'PHP Ethereum controller API provides additional methods. They are part of the <a href="https://github.com/digitaldonkey/ethereum-php">Ethereum PHP library</a>, but not part of JsonRPC-API standard.'];
141 $rows[] = [
"getMethodSignature('validateUserByHash(bytes32)')", $eth->getMethodSignature(
'validateUserByHash(bytes32)')];
if(!IS_PUBLIC) printTable($rows)
foreach($hosts as $url) status($eth)