1 Star 0 Fork 0

Lzzzj/EthereumPHP

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
Lzzzj-pinyutest Lzzzj 1 b119e0d 2年前
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Ethereum Client in PHP

Examples:

<?php
use EthereumPHP\EthereumClient;
use EthereumPHP\Types\BlockHash;
use EthereumPHP\Types\BlockNumber;

include 'vendor/autoload.php';

$randomAddress = new \EthereumPHP\Types\Address('0x7eff122b94897ea5b0e2a9abf47b86337fafebdc');
$randomHash = '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238';

$client = new EthereumClient('http://localhost:8545');

// net
echo $client->net()->version() , PHP_EOL;
echo $client->net()->listening() , PHP_EOL;
echo $client->net()->peerCount() , PHP_EOL;


// web3
echo $client->web3()->clientVersion() , PHP_EOL;
echo $client->web3()->sha3('0x68656c6c6f20776f726c64') , PHP_EOL;
echo $client->eth()->protocolVersion() , PHP_EOL;
echo $client->eth()->syncing() , PHP_EOL;

// eth
$coinbase = $client->eth()->coinbase();
if ($coinbase) {
    echo $coinbase->toString() , PHP_EOL;
}
echo $client->eth()->mining() , PHP_EOL;
echo $client->eth()->hashRate() , PHP_EOL;
echo $client->eth()->gasPrice()->toEther() , PHP_EOL;
foreach ($client->eth()->accounts() as $account) {
    echo $account->toString() , PHP_EOL;
}

echo $client->eth()->blockNumber() , PHP_EOL;
echo $client->eth()->getBalance($randomAddress, new BlockNumber())->toEther() , PHP_EOL;
echo $client->eth()->getTransactionCount($randomAddress, new BlockNumber()) , PHP_EOL;
echo $client->eth()->getBlockTransactionCountByHash(new BlockHash($randomHash)) , PHP_EOL;
echo $client->eth()->getUncleCountByBlockHash(new BlockHash($randomHash)) , PHP_EOL;
echo $client->eth()->getUncleCountByBlockNumber(new BlockNumber()) , PHP_EOL;
echo $client->eth()->getCode($randomAddress, new BlockNumber()) , PHP_EOL;
echo $client->eth()->sign($randomAddress, '0xdeadbeaf') , PHP_EOL;
foreach ($client->eth()->getCompilers() as $compiler) {
    echo $compiler , PHP_EOL;
}
print_r($client->eth()->compileSolidity('contract test { function multiply(uint a) returns(uint d) {   return a * 7;   } }"'));


// management: personal
foreach ($client->personal()->listAccounts() as $account) {
    echo $account->toString() , PHP_EOL;
}
$account = $client->personal()->newAccount('test');
echo $account->toString() , PHP_EOL;
echo $client->personal()->unlockAccount($account, 'test', 20) , PHP_EOL;

空文件

简介

1 展开 收起
PHP
取消

发行版 (1)

全部
so1
2年前

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/pinyutest/ethereum-php.git
git@gitee.com:pinyutest/ethereum-php.git
pinyutest
ethereum-php
EthereumPHP
master

搜索帮助