PHPackages                             furqansiddiqui/erc20-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. furqansiddiqui/erc20-php

ActiveLibrary[API Development](/categories/api)

furqansiddiqui/erc20-php
========================

Interact with any ERC20 standard/backward-compatible Ethereum token

0.4.0(3mo ago)16466.3k↓30.3%974MITPHPCI passing

Since May 9Pushed 3mo ago20 watchersCompare

[ Source](https://github.com/furqansiddiqui/erc20-php)[ Packagist](https://packagist.org/packages/furqansiddiqui/erc20-php)[ RSS](/packages/furqansiddiqui-erc20-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (15)Used By (4)

ERC-20 Token Library for PHP
============================

[](#erc-20-token-library-for-php)

[![Tests](https://github.com/furqansiddiqui/erc20-php/actions/workflows/tests.yml/badge.svg)](https://github.com/furqansiddiqui/erc20-php/actions/workflows/tests.yml)[![MIT License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

A PHP library for interacting with ERC-20 smart contracts on the Ethereum blockchain. This library uses the [ethereum-php](https://github.com/furqansiddiqui/ethereum-php) package for RPC communication and EVM interactions.

Features
--------

[](#features)

- Fetch token metadata (name, symbol, decimals, total supply).
- Retrieve account balances and allowances.
- Encode data for standard ERC-20 transactions (`transfer`, `transferFrom`, `approve`).
- Support for custom/extended ERC-20 ABIs.
- Fully compatible with PHP 8.5+.

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

[](#requirements)

- **PHP:** ^8.5
- **Extensions:** `openssl`, `gmp`, `bcmath`

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

[](#installation)

Install the package via Composer:

```
composer require furqansiddiqui/erc20-php
```

Usage
-----

[](#usage)

### Initialization

[](#initialization)

To start, you need an Ethereum RPC client (e.g., Geth or an Infura/Alchemy endpoint) and the `Erc20` handler.

```
use FurqanSiddiqui\Ethereum\Rpc\GethRpc;
use FurqanSiddiqui\Ethereum\Erc20\Erc20;
use FurqanSiddiqui\Ethereum\Keypair\EthereumAddress;

$rpc = new GethRpc("https://mainnet.infura.io/v3/YOUR_PROJECT_ID");
$erc20 = new Erc20($rpc);

// USDC Token Address
$usdcAddress = new EthereumAddress("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48");
$token = $erc20->deployedAt($usdcAddress);
```

### Token Metadata

[](#token-metadata)

```
echo "Name: " . $token->name() . PHP_EOL;
echo "Symbol: " . $token->symbol() . PHP_EOL;
echo "Decimals: " . $token->decimals() . PHP_EOL;
echo "Total Supply: " . $token->totalSupply() . PHP_EOL;
```

### Balances and Allowances

[](#balances-and-allowances)

```
$userAddress = new EthereumAddress("0x...");

// Get raw balance (uint256)
$balance = $token->balanceOf($userAddress);
echo "Raw Balance: " . $balance . PHP_EOL;

// Get allowance
$spender = new EthereumAddress("0x...");
$allowance = $token->allowance($userAddress, $spender);
```

### Encoding Transactions

[](#encoding-transactions)

This library helps you encode the `data` field for Ethereum transactions.

```
// Encode a transfer of 100 USDC (USDC has 6 decimals)
$toAddress = "0x...";
$amount = 100 * (10 ** 6);
$data = $token->encodeTransfer($toAddress, $amount);

// You can now use this $data in an 'eth_sendTransaction' or 'eth_sendRawTransaction' call
```

Extending for Custom ABIs
-------------------------

[](#extending-for-custom-abis)

If you are dealing with a contract that follows ERC-20 but has additional methods, you can extend `Erc20ContractBase`.

```
use FurqanSiddiqui\Ethereum\Erc20\Erc20ContractBase;
use FurqanSiddiqui\Ethereum\Evm\ContractMethod;
use FurqanSiddiqui\Ethereum\Evm\ContractMethodType;
use FurqanSiddiqui\Ethereum\Evm\AbiParam;

class MyCustomTokenAbi extends Erc20ContractBase
{
    public function __construct()
    {
        parent::__construct();

        // Add a custom method: burn(uint256)
        $burn = new ContractMethod(ContractMethodType::Function, "burn", false, false);
        $burn->appendInput(new AbiParam("uint256", null));
        $this->append($burn);
    }
}

// Usage
$erc20 = new Erc20($rpc, new MyCustomTokenAbi());
```

Testing
-------

[](#testing)

The library includes a PHPUnit test suite. To run the tests, ensure you have dependencies installed:

```
composer install
./vendor/bin/phpunit
```

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](LICENSE).

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance82

Actively maintained with recent releases

Popularity49

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 97.4% 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 ~258 days

Recently: every ~482 days

Total

12

Last Release

91d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11485189?v=4)[M. Furqan Siddiqui](/maintainers/furqansiddiqui)[@furqansiddiqui](https://github.com/furqansiddiqui)

---

Top Contributors

[![furqansiddiqui](https://avatars.githubusercontent.com/u/11485189?v=4)](https://github.com/furqansiddiqui "furqansiddiqui (37 commits)")[![survivordj](https://avatars.githubusercontent.com/u/6272137?v=4)](https://github.com/survivordj "survivordj (1 commits)")

---

Tags

ethereumethgethethereum-goerc20erc223

### Embed Badge

![Health badge](/badges/furqansiddiqui-erc20-php/health.svg)

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

###  Alternatives

[furqansiddiqui/ethereum-rpc

Ethereum (geth) RPC client

2550.6k4](/packages/furqansiddiqui-ethereum-rpc)[drlecks/simple-web3-php

Web3 library in PHP

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

PHPackages © 2026

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