PHPackages                             happyyyyyyyyy/web3 - 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. happyyyyyyyyy/web3

ActiveLibrary[API Development](/categories/api)

happyyyyyyyyy/web3
==================

Ethereum web3 interface.

1.2(4y ago)05221MITPHPPHP ^7.1

Since Nov 6Pushed 4y ago1 watchersCompare

[ Source](https://github.com/happyyyyyyyyy/web3)[ Packagist](https://packagist.org/packages/happyyyyyyyyy/web3)[ RSS](/packages/happyyyyyyyyy-web3/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (4)Used By (1)

web3.php
========

[](#web3php)

[![Build Status](https://camo.githubusercontent.com/043a504181cbf6ec7b0aa4c4927362abde2f7575b0615d260f451725494ac79a/68747470733a2f2f7472617669732d63692e6f72672f6169776f7a68652f776562332e7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/aiwozhe/web3.php)[![codecov](https://camo.githubusercontent.com/73abad8ea98ed6231b95c5bffd022080a269f1e3e37c7840de242e3d81829be1/68747470733a2f2f636f6465636f762e696f2f67682f6169776f7a68652f776562332e7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/aiwozhe/web3.php)[![Join the chat at https://gitter.im/web3-php/web3.php](https://camo.githubusercontent.com/4b8417cc6318d32b8268f39a1dc8c8f9099e1b7ff1258aa4ed44ba1459056553/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6769747465722d6a6f696e253230636861742d627269676874677265656e2e737667)](https://gitter.im/web3-php/web3.php)[![Licensed under the MIT License](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](https://github.com/aiwozhe/web3.php/blob/master/LICENSE)

A php interface for interacting with the Ethereum blockchain and ecosystem.

Install
=======

[](#install)

Set minimum stability to dev

```
"minimum-stability": "dev"

```

Then

```
composer require happyyyyyyyyy/web3

```

Or you can add this line in composer.json

```
"happyyyyyyyyy/web3": "*"

```

Usage
=====

[](#usage)

### New instance

[](#new-instance)

```
use Web3\Web3;

$web3 = new Web3('http://localhost:8545');
```

### Using provider

[](#using-provider)

```
use Web3\Web3;
use Web3\Providers\HttpProvider;
use Web3\RequestManagers\HttpRequestManager;

$web3 = new Web3(new HttpProvider(new HttpRequestManager('http://localhost:8545')));

// timeout
$web3 = new Web3(new HttpProvider(new HttpRequestManager('http://localhost:8545', 0.1)));
```

### You can use callback to each rpc call:

[](#you-can-use-callback-to-each-rpc-call)

```
$web3->clientVersion(function ($err, $version) {
    if ($err !== null) {
        // do something
        return;
    }
    if (isset($version)) {
        echo 'Client version: ' . $version;
    }
});
```

### Eth

[](#eth)

```
use Web3\Web3;

$web3 = new Web3('http://localhost:8545');
$eth = $web3->eth;
```

Or

```
use Web3\Eth;

$eth = new Eth('http://localhost:8545');
```

### Net

[](#net)

```
use Web3\Web3;

$web3 = new Web3('http://localhost:8545');
$net = $web3->net;
```

Or

```
use Web3\Net;

$net = new Net('http://localhost:8545');
```

### Batch

[](#batch)

web3

```
$web3->batch(true);
$web3->clientVersion();
$web3->hash('0x1234');
$web3->execute(function ($err, $data) {
    if ($err !== null) {
        // do something
        // it may throw exception or array of exception depends on error type
        // connection error: throw exception
        // json rpc error: array of exception
        return;
    }
    // do something
});
```

eth

```
$eth->batch(true);
$eth->protocolVersion();
$eth->syncing();

$eth->provider->execute(function ($err, $data) {
    if ($err !== null) {
        // do something
        return;
    }
    // do something
});
```

net

```
$net->batch(true);
$net->version();
$net->listening();

$net->provider->execute(function ($err, $data) {
    if ($err !== null) {
        // do something
        return;
    }
    // do something
});
```

personal

```
$personal->batch(true);
$personal->listAccounts();
$personal->newAccount('123456');

$personal->provider->execute(function ($err, $data) {
    if ($err !== null) {
        // do something
        return;
    }
    // do something
});
```

### Contract

[](#contract)

```
use Web3\Contract;

$contract = new Contract('http://localhost:8545', $abi);

// deploy contract
$contract->bytecode($bytecode)->new($params, $callback);

// call contract function
$contract->at($contractAddress)->call($functionName, $params, $callback);

// change function state
$contract->at($contractAddress)->send($functionName, $params, $callback);

// estimate deploy contract gas
$contract->bytecode($bytecode)->estimateGas($params, $callback);

// estimate function gas
$contract->at($contractAddress)->estimateGas($functionName, $params, $callback);

// get constructor data
$constructorData = $contract->bytecode($bytecode)->getData($params);

// get function data
$functionData = $contract->at($contractAddress)->getData($functionName, $params);
```

Assign value to outside scope(from callback scope to outside scope)
===================================================================

[](#assign-value-to-outside-scopefrom-callback-scope-to-outside-scope)

Due to callback is not like javascript callback, if we need to assign value to outside scope, we need to assign reference to callback.

```
$newAccount = '';

$web3->personal->newAccount('123456', function ($err, $account) use (&$newAccount) {
    if ($err !== null) {
        echo 'Error: ' . $err->getMessage();
        return;
    }
    $newAccount = $account;
    echo 'New account: ' . $account . PHP_EOL;
});
```

Examples
========

[](#examples)

To run examples, you need to run ethereum blockchain local (testrpc).

If you are using docker as development machain, you can try [ethdock](https://github.com/aiwozhe/ethdock) to run local ethereum blockchain, just simply run `docker-compose up -d testrpc` and expose the `8545` port.

API
===

[](#api)

Todo.

License
=======

[](#license)

MIT

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

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 ~5 days

Total

3

Last Release

1636d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a73648dff423f35dca0377e30696e26721bade85b6d23997534b844597443de?d=identicon)[buger](/maintainers/buger)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/happyyyyyyyyy-web3/health.svg)

```
[![Health](https://phpackages.com/badges/happyyyyyyyyy-web3/health.svg)](https://phpackages.com/packages/happyyyyyyyyy-web3)
```

###  Alternatives

[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[packbackbooks/lti-1p3-tool

A library used for building IMS-certified LTI 1.3 tool providers in PHP.

51438.3k2](/packages/packbackbooks-lti-1p3-tool)[yoti/yoti-php-sdk

Yoti SDK for quickly integrating your PHP backend with Yoti

27539.9k1](/packages/yoti-yoti-php-sdk)[hoels/app-store-server-library-php

The PHP server library for the App Store Server API and App Store Server Notifications.

44162.2k](/packages/hoels-app-store-server-library-php)[sc0vu/web3.php

Ethereum web3 interface.

96165.3k17](/packages/sc0vu-web3php)[soneso/stellar-php-sdk

Stellar PHP SDK for the Stellar Network

4048.2k4](/packages/soneso-stellar-php-sdk)

PHPackages © 2026

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