PHPackages                             ericychu/ethereum-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ericychu/ethereum-php

AbandonedArchivedLibrary[API Development](/categories/api)

ericychu/ethereum-php
=====================

Ethereum client for PHP.

0.9.8(7y ago)5211020[2 issues](https://github.com/EricYChu/ethereum-php/issues)MITPHP

Since Mar 25Pushed 7y ago1 watchersCompare

[ Source](https://github.com/EricYChu/ethereum-php)[ Packagist](https://packagist.org/packages/ericychu/ethereum-php)[ Docs](https://github.com/ericychu/ethereum-php)[ RSS](/packages/ericychu-ethereum-php/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (3)Versions (20)Used By (0)

Ethereum Client for PHP
=======================

[](#ethereum-client-for-php)

PHP 版本以太坊 JSON RPC 客户端。

可通过简单的添加合约地址和 ABI 来方便的调用合约内的方法，对于需要对交易签名的请求，客户端会自动完成。

支持对事件（Log）的监听，但需要通过定时器执行 `\Ethereum\Client::synchronizer->sync()` 方法来轮询， 当有事件到达会执行自定义的回调并传递一个 `\Ethereum\Types\Event` 的实例，该实例包含了反序列化后的事件输入和相关的区块、交易数据。

JSON RPC API 实现度
----------------

[](#json-rpc-api-实现度)

已实现

- eth\_\*
- net\_\*
- web3\_\*

未实现

- shh\_\*

依赖
--

[](#依赖)

```
php-64bit: ^7.2
ext-gmp: ^7.2
ext-scrypt: ^1.4
ext-secp256k1: ^0.1.0
ext-keccak: ^0.2
graze/guzzle-jsonrpc: ^3.2
bitwasp/buffertools: ^0.5.0

```

- ext-scrypt:
- ext-secp256k1:
- ext-keccak:

使用
--

[](#使用)

### 安装

[](#安装)

```
composer require ericychu/ethereum-php

```

### 示例

[](#示例)

#### 实例化客户端

[](#实例化客户端)

```
$client = new Ethereum\Client(
    // JSON RPC 地址
    'https://api.infura.io/v1/jsonrpc/ropsten',
    // 以太坊网络 ID
    3,
    // 节点账户的 Keystore
    '',
    // Keystore 的密码
    '',
    // 存储实例，用来保存一些状态值，可以通过实现 \Ethereum\StorageInterface 接口使用你自己的存储
    new \Ethereum\Storage
);

```

#### 添加合约

[](#添加合约)

```
$client->contracts
    ->add(
        // 合约别名
        'test_contract',
        // 合约地址
        '',
        // 合约 ABI（JSON String）
        ''
    );

```

#### 调用合约中的方法

[](#调用合约中的方法)

`pure` 和 `view` 的方法，可以直接以数组的形式返回反序列化后的数据；`nonpayable` 和 `payable` 的方法返回交易的哈希（`\Ethereum\Types\Hash` 实例）。

```
$result = $client->contracts->test_contract->call('test_function', ['test_arg_1', 'test_arg_2']);

```

#### 监听事件

[](#监听事件)

这里的事件名称是你在合约中定义的事件名称。

注意，监听事件需要通过定时器执行 `\Ethereum\Client::synchronizer->sync()` 方法来轮询以太坊节点。当有事件到达会执行自定义的回调并传递一个 `\Ethereum\Types\Event` 的实例，该实例包含了反序列化后的事件输入和相关的区块、交易数据。

```
$client->contracts->test_contract->watch('Event1', function (\Ethereum\Types\Event $data) {
    var_dump($data);
});

```

如果使用 Swoole，可以通过 Swoole 的定时器来来轮询。

```
swoole_timer_tick(1000, function() use ($client) {
    $client->synchronizer->sync();
});

```

#### 调用 JSON RPC API

[](#调用-json-rpc-api)

支持的方法请查阅 `\Ethereum\Methods\Eth`、 `\Ethereum\Methods\Web3` 和 `\Ethereum\Methods\Net` 类。

```
echo $client->eth()->protocolVersion();
echo $client->web3()->clientVersion();
echo $client->net()->version();

```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~20 days

Recently: every ~74 days

Total

18

Last Release

2616d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6fc06d3a44afebb588f3eba3f7f2515527e1796fa061cda5aa95ece1e072510c?d=identicon)[EricYZhu](/maintainers/EricYZhu)

---

Top Contributors

[![ericyzhu](https://avatars.githubusercontent.com/u/1786762?v=4)](https://github.com/ericyzhu "ericyzhu (3 commits)")

---

Tags

ethereumethereum-clientethereum-phpphpweb3ethereumweb3

### Embed Badge

![Health badge](/badges/ericychu-ethereum-php/health.svg)

```
[![Health](https://phpackages.com/badges/ericychu-ethereum-php/health.svg)](https://phpackages.com/packages/ericychu-ethereum-php)
```

###  Alternatives

[drlecks/simple-web3-php

Web3 library in PHP

7641.6k2](/packages/drlecks-simple-web3-php)[furqansiddiqui/erc20-php

Interact with any ERC20 standard/backward-compatible Ethereum token

16466.3k4](/packages/furqansiddiqui-erc20-php)[coinbase/coinbase-commerce

Coinbase Commerce API library

148275.7k2](/packages/coinbase-coinbase-commerce)[coinpaymentsnet/coinpayments-php

A PHP wrapper for the CoinPayments.net v1 API.

55126.2k](/packages/coinpaymentsnet-coinpayments-php)[maslakoff/php-etherscan-api

PHP client for the Etherscan API

2922.7k](/packages/maslakoff-php-etherscan-api)[crypto-pay/binancepay

Binance Pay API for Laravel

222.3k](/packages/crypto-pay-binancepay)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
