承接 ecourty/ethereum-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ecourty/ethereum-php

最新稳定版本:1.1.0

Composer 安装命令:

composer require ecourty/ethereum-php

包简介

Interact with an Ethereum node via JSON-RPC using PHP

README 文档

README

PHP CI

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_version
  • net_listening
  • net_peerCount
  • eth_protocolVersion
  • eth_syncing
  • eth_chainId
  • eth_mining
  • eth_hashrate
  • eth_gasPrice
  • eth_accounts
  • eth_blockNumber
  • eth_getBalance
  • eth_getStorageAt
  • eth_getTransactionCount
  • eth_getBlockTransactionCountByHash
  • eth_getBlockTransactionCountByNumber
  • eth_getUncleCountByBlockHash
  • eth_getUncleCountByBlockNumber
  • eth_getCode
  • eth_sign
  • eth_signTransaction
  • eth_sendTransaction
  • eth_sendRawTransaction
  • eth_call
  • eth_estimateGas
  • eth_getBlockByHash
  • eth_getBlockByNumber
  • eth_getTransactionByHash
  • eth_getTransactionByBlockHashAndIndex
  • eth_getTransactionByBlockNumberAndIndex
  • eth_getTransactionReceipt
  • eth_getUncleByBlockHashAndIndex
  • eth_getUncleByBlockNumberAndIndex
  • eth_newFilter
  • eth_newBlockFilter
  • eth_newPendingTransactionFilter
  • eth_uninstallFilter
  • eth_getFilterChanges
  • eth_getFilterLogs
  • eth_getLogs

统计信息

  • 总下载量: 81
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-20