加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ethereum.php 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
slagga 提交于 2020-04-25 20:38 . first commit
<?php
/**
* Terminal Test
* php .\ethereum.php getTransactionByHash 0x01c5a8461d06c2c195035c148af0f871c7679841d86ae5bb98676bb2d8e68dfa
* php .\ethereum.php getTransactionByAddress 0xdae787ec66e65c60ad35203800b97b45fcb0f909 1048576
*/
$arg1 = $argv[1];
$arg2 = $argv[2];
$arg3 = $argv[3];
switch ($arg1) {
case "getTransactionByHash":
$transaction = getTransactionByHash($arg2);
var_dump($transaction);
break;
case "getTransactionByAddress":
$transaction = getTransactionByAddress($arg2, $arg3);
var_dump($transaction);
break;
default:
var_dump("nothing to do");
}
function getTransactionByHash($hash) {
require_once('./lib/clienteth.php');
$ethclient = new EthClient("192.168.1.217", 8545);
return $ethclient->eth_getTransactionByHash($hash);
}
function getTransactionByAddress($address, $startnumber) {
require_once('./lib/clienteth.php');
$ethclient = new EthClient("192.168.1.217", 8545);
$endnumber = $ethclient->eth_blockNumber(true);
if ($endnumber == 0) $endnumber = $startnumber + 1;
$transactionlist = [];
for ($i = $startnumber; $i <= $endnumber; $i++) {
echo "blocknumber: " . $i . "\n";
$block = $ethclient->eth_getBlockByNumber($ethclient->encode_dec($i), true);
if ($block['transactions'] != NULL) {
for ($k = 0; $k < count($block['transactions']); $k++) {
$transactionlist[] = $block['transactions'][$k];
}
}
}
echo "\n\n\n";
return $transactionlist;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化