PHPackages                             bi-php/web3-decode-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. bi-php/web3-decode-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bi-php/web3-decode-php
======================

A PHP library for decoding Ethereum logs and errors

v1.0.0(1y ago)119MITPHPPHP ^7.4 || ^8.0

Since Mar 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/bernarditoro/web3-decode-php)[ Packagist](https://packagist.org/packages/bi-php/web3-decode-php)[ RSS](/packages/bi-php-web3-decode-php/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

Web3 Decode PHP
===============

[](#web3-decode-php)

A PHP library for decoding Ethereum logs and errors using contract ABIs. This library provides utilities to decode Ethereum (custom) error messages and event logs, making it easier to work with smart contract data.

Features
--------

[](#features)

- **Decode Ethereum Errors**: Decode error messages from Ethereum transactions using the contract ABI.
- **Decode Ethereum Logs**: Decode event logs emitted by smart contracts using the contract ABI.
- **Supports Indexed and Non-Indexed Parameters**: Handles both indexed and non-indexed parameters in event logs.

Installation
------------

[](#installation)

You can install the library via Composer:

```
composer require bi/web3-decode-php
```

Usage
-----

[](#usage)

### Decoding Ethereum Errors

[](#decoding-ethereum-errors)

To decode an Ethereum error, use the `decodeError` function:

```
require 'vendor/autoload.php';

use Web3DecodePhp\DecodeError;

$errorSelector = '0x12345678'; // Example error selector
$abi = [
    [
        'type' => 'error',
        'name' => 'MyError',
        'inputs' => [
            ['type' => 'uint256'],
            ['type' => 'address']
        ]
    ]
];

$decodedError = DecodeError::decode($errorSelector, $abi);

echo $decodedError;
```

### Decoding Ethereum Logs

[](#decoding-ethereum-logs)

To decode an Ethereum log, use the `DecodeLog` class:

```
require 'vendor/autoload.php';

use Web3DecodePhp\DecodeLog;

$eventAbi = [
    'name' => 'Transfer',
    'inputs' => [
        ['name' => 'from', 'type' => 'address', 'indexed' => true],
        ['name' => 'to', 'type' => 'address', 'indexed' => true],
        ['name' => 'value', 'type' => 'uint256', 'indexed' => false],
    ]
];

$log = (object) [
    "address" => "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359", // Contract address
    "topics" => [
        "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", // Event signature
        "0x0000000000000000000000004bbeeb066ed09b7aed07bf39eee0460dfa261520", // from (indexed)
        "0x000000000000000000000000f977814e90da44bfa03b6295a0616a897441acec", // to (indexed)
    ],
    "data" => "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000", // value (non-indexed)
    "blockHash" => "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "blockNumber" => "0x123456",
    "blockTimestamp" => "0x6789abcd",
    "transactionHash" => "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
    "transactionIndex" => "0x0",
    "logIndex" => "0x1",
    "removed" => false
];

$decoder = new DecodeLog([$eventAbi]);
$decodedLog = $decoder->decode($log);

// Output the decoded log
echo json_encode($decodedLog, JSON_PRETTY_PRINT);
```

API Reference
-------------

[](#api-reference)

### `decodeError(string $errorSelector, array $abi): ?array`

[](#decodeerrorstring-errorselector-array-abi-array)

Decodes an Ethereum error from its selector and ABI.

- **Parameters**:
    - `$errorSelector`: The error selector (hex string).
    - `$abi`: The contract ABI (including error definitions).
- **Returns**: An array containing the decoded error, or `null` if no match is found.

### `DecodeLog`

[](#decodelog)

A class for decoding Ethereum event logs.

#### `__construct(array $contractAbi)`

[](#__constructarray-contractabi)

Initializes the decoder with the contract ABI.

- **Parameters**:
    - `$contractAbi`: The contract ABI (including event definitions).

#### `decode(object $log): array`

[](#decodeobject-log-array)

Decodes an Ethereum log.

- **Parameters**:
    - `$log`: The log object to decode.
- **Returns**: An array containing the decoded log data.

Contributing
------------

[](#contributing)

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance42

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

471d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/87977234?v=4)[Bernard Itoro](/maintainers/bernarditoro)[@bernarditoro](https://github.com/bernarditoro)

---

Top Contributors

[![bernarditoro](https://avatars.githubusercontent.com/u/87977234?v=4)](https://github.com/bernarditoro "bernarditoro (2 commits)")

### Embed Badge

![Health badge](/badges/bi-php-web3-decode-php/health.svg)

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

###  Alternatives

[fancyguy/webroot-installer

A composer installer for libraries that live in an application webroot.

1311.3M15](/packages/fancyguy-webroot-installer)

PHPackages © 2026

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