ecourty/ethereum-php
最新稳定版本:1.1.0
Composer 安装命令:
composer require ecourty/ethereum-php
包简介
Interact with an Ethereum node via JSON-RPC using PHP
关键字:
README 文档
README
Ethereum PHP allows you to interact with the Ethereum blockchain using PHP.
All you need to start is a running Ethereum node, with the JSON-RPC interface enabled.
Installation
Install this package using composer:
composer require ecourty/ethereum-php
Usage
Connecting to a Node
<?php use EthereumPHP\Client\EthereumClient; $client = new EthereumClient('http://localhost:8545'); // ... $balance = $clent->getBalance('0x1234567890123456789012345678901234567890'); // ... $latestBlock = $client->getLastBlock(); // ...
Using the EthereumConverter utility
EthereumPHP\Utils\EthereumConverter provides a set of methods to convert between different Ethereum units (wei, gwei, ether).
<?php use EthereumPHP\Utils\EthereumConverter; // ... $weiAmount = 14500000789000000; $etherAmount = EthereumConverter::weiToEther($weiAmount); $gweiAmount = EthereumConverter::weiToGwei($weiAmount);
Remarks
Precise numbers such as WEI / GWEI / ETHER amounts are represented as strings instead of float or int to avoid precision loss.
The bcmath extension is needed for this library to work.
Features
EthereumPHP comes with a handful of methods to interact with the Ethereum blockchain.
Here is a list of all currently supported JSON-RPC methods:
net_versionnet_listeningnet_peerCounteth_protocolVersioneth_syncingeth_chainIdeth_miningeth_hashrateeth_gasPriceeth_accountseth_blockNumbereth_getBalanceeth_getStorageAteth_getTransactionCounteth_getBlockTransactionCountByHasheth_getBlockTransactionCountByNumbereth_getUncleCountByBlockHasheth_getUncleCountByBlockNumbereth_getCodeeth_signeth_signTransactioneth_sendTransactioneth_sendRawTransactioneth_calleth_estimateGaseth_getBlockByHasheth_getBlockByNumbereth_getTransactionByHasheth_getTransactionByBlockHashAndIndexeth_getTransactionByBlockNumberAndIndexeth_getTransactionReceipteth_getUncleByBlockHashAndIndexeth_getUncleByBlockNumberAndIndexeth_newFiltereth_newBlockFiltereth_newPendingTransactionFiltereth_uninstallFiltereth_getFilterChangeseth_getFilterLogseth_getLogs
统计信息
- 总下载量: 81
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-20