PHPackages                             amashukov/abi-encoder-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. amashukov/abi-encoder-php

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

amashukov/abi-encoder-php
=========================

Solidity ABI calldata encoder in pure PHP — function selectors plus static (address/uint/int/bytesN) and dynamic (string/bytes) types, byte-for-byte equivalent to ethers.js v6.

v0.1.0(2mo ago)0357↑31.4%2MITPHPPHP &gt;=8.3CI passing

Since May 24Pushed 2mo agoCompare

[ Source](https://github.com/AndreyMashukov/abi-encoder-php)[ Packagist](https://packagist.org/packages/amashukov/abi-encoder-php)[ RSS](/packages/amashukov-abi-encoder-php/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (6)Versions (2)Used By (2)

amashukov/abi-encoder-php
=========================

[](#amashukovabi-encoder-php)

Solidity ABI calldata encoder in pure PHP — byte-for-byte parity with ethers.js v6.

[![CI](https://camo.githubusercontent.com/4901bcfbaef53703ff2acde8172355af61c37d35c71407bc6258898f233c57c8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f416e647265794d617368756b6f762f6162692d656e636f6465722d7068702f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/AndreyMashukov/abi-encoder-php/actions)[![PHPStan L9](https://camo.githubusercontent.com/15184d00ff6bb0a6831360bb709d42c3bb9a3a21795bd6894c613034d1cb026c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f416e647265794d617368756b6f762f6162692d656e636f6465722d7068702f7374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d5048505374616e2532304c39)](https://github.com/AndreyMashukov/abi-encoder-php/actions)[![Latest Version](https://camo.githubusercontent.com/3e10ce96f0c6e0b48d7e69b58bba8ba11b71d381068c8ae11448c4e935f79bb7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616d617368756b6f762f6162692d656e636f6465722d706870)](https://packagist.org/packages/amashukov/abi-encoder-php)[![Downloads](https://camo.githubusercontent.com/98659ab4204f7576b86aa4d4b3e4c0ef77bcc556e70c3771a3f752d288292b88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616d617368756b6f762f6162692d656e636f6465722d706870)](https://packagist.org/packages/amashukov/abi-encoder-php)[![PHP](https://camo.githubusercontent.com/f4819b8601ecbc26ee50c279e3d4e5ddf55c0ee62db9fd1c76ae75bcae139981/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f616d617368756b6f762f6162692d656e636f6465722d7068702f706870)](https://packagist.org/packages/amashukov/abi-encoder-php)[![License](https://camo.githubusercontent.com/efa62e2f3c79e14fed839131c015507189aa6cd17c4fa5fff2f4c8f3760970ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616d617368756b6f762f6162692d656e636f6465722d706870)](LICENSE)[![Stars](https://camo.githubusercontent.com/b04b89fb17c9b8d2b62ed4a4ab049a4203492bc6e273f9bcf2b06e570abfe06c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f416e647265794d617368756b6f762f6162692d656e636f6465722d7068703f7374796c653d736f6369616c)](https://github.com/AndreyMashukov/abi-encoder-php)

Encode **Ethereum / EVM Solidity ABI calldata** in pure PHP: function selectors (`methodId`), static head types (`address`, `uint8` / `uint24` / `uint256`) and top-level dynamic types (`bytes`, `string`). Output is **byte-for-byte equivalent to `ethers.js` v6** `Interface.encodeFunctionData`, so calldata built in PHP matches what your JavaScript tooling and Solidity contracts expect.

Features
--------

[](#features)

- Function selector (`methodId`) from a canonical signature via keccak-256.
- Full call encoding (selector + head + dynamic tail) in one call.
- Component encoders: `encodeAddress`, `encodeUint`, `encodeBytes`.
- Bigint-safe `uint256` via `ext-gmp` — accepts hex or decimal strings, handles max uint256.
- Byte-for-byte parity with ethers.js v6 (cross-validated in tests).
- PHPStan level 9 clean, `strict_types`.

Why amashukov/abi-encoder-php
-----------------------------

[](#why-amashukovabi-encoder-php)

Most PHP web3 stacks pull in `web3p/web3.php` (and its `web3p/ethereum-abi`) for ABI encoding, which is a much larger surface than a contract call usually needs. This package is intentionally narrow and dependency-light: it covers the head-only static types and top-level dynamic `bytes` / `string` that real EVM contract calls use, with explicit ethers.js v6 parity as the correctness bar. If you only need to build calldata for `eth_sendRawTransaction`, this is the focused tool.

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

[](#installation)

```
composer require amashukov/abi-encoder-php
```

Usage
-----

[](#usage)

### Function selector

[](#function-selector)

```
use Amashukov\AbiEncoder\AbiEncoder;

AbiEncoder::methodId('withdraw(address,uint256)');   // 'f3fef3a3'
```

The selector is the first 4 bytes of the keccak-256 hash of the canonical signature, returned as 8 hex chars (no `0x`).

### Encode a full call

[](#encode-a-full-call)

```
$calldata = AbiEncoder::encodeCall('withdraw(address,uint256)', [
    ['address', '0x1234567890123456789012345678901234567890'],
    ['uint256', '500000000000000000'],   // decimal string; bigints supported via ext-gmp
]);
// 0xf3fef3a3000000…0006f05b59d3b20000
```

Each argument is a `[type, value]` pair. Supported types: `address`, `uint8`, `uint24`, `uint256`, `bytes`, `string`. Dynamic types (`bytes`, `string`) are placed in the tail with the correct head offset, exactly as the ABI spec + ethers.js produce.

### Encode individual components

[](#encode-individual-components)

```
AbiEncoder::encodeAddress('0xABCDEF…');         // left-padded to 32 bytes, lowercased
AbiEncoder::encodeUint('0xFF');                 // accepts hex or decimal; bigint-safe
AbiEncoder::encodeUint('115792089237316195423570985008687907853269984665640564039457584007913129639935'); // max uint256
AbiEncoder::encodeBytes('0xdeadbeef');          // length word + right-padded data
AbiEncoder::encodeBytes('v1', isString: true);  // UTF-8 string as dynamic bytes
```

### Scope

[](#scope)

Intentionally narrow — covers the head-only static types and top-level dynamic `bytes` / `string` that real EVM contract calls use. Nested dynamic types (`bytes[]`, `string[]`, dynamic tuples) are out of scope.

Requirements
------------

[](#requirements)

- PHP 8.3+
- `ext-gmp`
- [amashukov/keccak-php](https://github.com/AndreyMashukov/keccak-php) (for the selector hash)

Related packages
----------------

[](#related-packages)

PackageTierPurpose[amashukov/keccak-php](https://github.com/AndreyMashukov/keccak-php)leafkeccak-256 hashing (selector hash)[amashukov/eip1559-tx-signer-php](https://github.com/AndreyMashukov/eip1559-tx-signer-php)compositeEIP-1559 raw tx assembly + signing[amashukov/rlp-php](https://github.com/AndreyMashukov/rlp-php)leafRLP encoding[amashukov/secp256k1-php](https://github.com/AndreyMashukov/secp256k1-php)leafECDSA sign / pubkey derivation[amashukov/eth-rpc-client-php](https://github.com/AndreyMashukov/eth-rpc-client-php)RPCEthereum JSON-RPC client[amashukov/eth-php](https://github.com/AndreyMashukov/eth-php)metaEVM umbrella packageQuality
-------

[](#quality)

- PHPStan level 9.
- php-cs-fixer with the `@PER-CS` ruleset.
- GitHub Actions CI on every push.
- Byte-for-byte parity tests against ethers.js v6 `Interface.encodeFunctionData`.

License
-------

[](#license)

MIT.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance88

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

62d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b3e86ca79a82515b23e0239b1d3616c747e59b64c40e169d538d5c759c9bbc4?d=identicon)[Andrey Mashukov](/maintainers/Andrey%20Mashukov)

---

Top Contributors

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

---

Tags

abiblockchaincalldataethereumethersevmphpsolidityencodingethereumevmsolidityabicalldata

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/amashukov-abi-encoder-php/health.svg)

```
[![Health](https://phpackages.com/badges/amashukov-abi-encoder-php/health.svg)](https://phpackages.com/packages/amashukov-abi-encoder-php)
```

###  Alternatives

[paragonie/constant_time_encoding

Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)

902363.2M194](/packages/paragonie-constant-time-encoding)[paquettg/string-encode

Facilitating the process of altering string encoding in PHP.

699.1M43](/packages/paquettg-string-encode)[onnov/detect-encoding

Text encoding definition class instead of mb\_detect\_encoding. Defines: utf-8, windows-1251, koi8-r, iso-8859-5, ibm866, .....

224.1M18](/packages/onnov-detect-encoding)[kornrunner/solidity

Pure PHP implementation of Solidity

2040.6k11](/packages/kornrunner-solidity)[kornrunner/ethereum-offline-raw-tx

Pure PHP Ethereum Offline Raw Transaction Signer

62204.6k24](/packages/kornrunner-ethereum-offline-raw-tx)[jawira/plantuml-encoding

PlantUML encoding functions

20627.2k12](/packages/jawira-plantuml-encoding)

PHPackages © 2026

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