Ethereum PHP
PHP interface to Ethereum JSON-RPC API.
schema-example.php
Go to the documentation of this file.
1 <?php
9 
13 define('IS_PUBLIC', TRUE);
14 
15 require_once __DIR__ . '/examples.inc.php';
16 
20 $schema = Ethereum::getDefinition();
22 echo "<h1>SCHEMA</h1>";
23 
24 foreach ($schema['methods'] as $fn_name => $params) {
25 
26  // $params[0] = Constructor types.
27  // $params[1] = Return types.
28 
29  echo "<h3>" . $fn_name . "()</h3>";
30  echo '<p><small>See Ethereum Wiki <a href="https://github.com/ethereum/wiki/wiki/JSON-RPC#' . strtolower($fn_name) . '">' . $fn_name . '</a></small></p>';
31  echo "<h6>params</h6>";
32 
33  if (count($params[0])) {
34  echo "Arguments in definition: <pre>" . print_r($params[0], true) . "</pre>";
35 
36  foreach ($params[0] as $i => $param) {
37  echo "<p>Argument $i must use Ethereum data type class: <b>" . EthDataType::getTypeClass($param) . "</b></p>";
38  }
39  }
40  else {
41  echo "No arguments";
42  }
43 
44  echo "<h6>return</h6>";
45  echo "Return value in definition: <pre>" . print_r($params[1],1) . "</pre>";
46  if (is_array($params[1])) {
47  echo "<p>Return is <b>Array</b> of class: <b>" . EthDataType::getTypeClass($params[1][0]) . "</b></p>";
48  }
49  else {
50  echo "<p>Return value will be of class: <b>" . EthDataType::getTypeClass($params[1]) . "</b></p>";
51  }
52  echo "<hr />";
53 }
$schema