PHPackages                             kornrunner/ethereum-token - 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. kornrunner/ethereum-token

ActiveLibrary

kornrunner/ethereum-token
=========================

PHP Ethereum Token Utils

0.2.0(5mo ago)1412.9k↓33.3%41MITPHPPHP &gt;=8.1CI passing

Since Feb 8Pushed 1mo ago2 watchersCompare

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

READMEChangelog (3)Dependencies (1)Versions (4)Used By (1)

php-ethereum-token [![Tests](https://github.com/kornrunner/php-ethereum-token/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/kornrunner/php-ethereum-token/actions/workflows/tests.yml) [![Coverage Status](https://camo.githubusercontent.com/b7f2bff6efc2cbace07e5c3823abce25c12a1062600fe1a8daeca7e2cd52f588/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6b6f726e72756e6e65722f7068702d657468657265756d2d746f6b656e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/kornrunner/php-ethereum-token?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/9c2b3c2b864800fc0382484bd28922b243deba91be436e297e652b882545374c/68747470733a2f2f706f7365722e707567782e6f72672f6b6f726e72756e6e65722f657468657265756d2d746f6b656e2f762f737461626c65)](https://packagist.org/packages/kornrunner/ethereum-token)
================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#php-ethereum-token---)

PHP Ethereum Token Utils

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

[](#installation)

```
$ composer require kornrunner/ethereum-token
```

Usage
-----

[](#usage)

To prepare a offline transaction, using `kornrunner/ethereum-offline-raw-tx`

### Transfer

[](#transfer)

```
use kornrunner\Ethereum\Token;
use kornrunner\Ethereum\Transaction;

$nonce    = '04';
$gasPrice = '03f5476a00';
$gasLimit = '027f4b';
$to       = '1a8c8adfbe1c59e8b58cc0d515f07b7225f51c72';

$privateKey = 'b2f2698dd7343fa5afc96626dee139cb92e58e5d04e855f4c712727bf198e898';

$token = new Token;
$usdt  = new Token\USDT;

$amount = 20;
$hexAmount = $token->hexAmount($usdt, $amount);
// 0x1312d00

$data = $token->getTransferData($to, $hexAmount);
// 0xa9059cbb0000000000000000000000001a8c8adfbe1c59e8b58cc0d515f07b7225f51c720000000000000000000000000000000000000000000000000000000001312d00

$transaction = new Transaction($nonce, $gasPrice, $gasLimit, $usdt::ADDRESS, '', $data);
$transaction->getRaw($privateKey);
// f8a9048503f5476a0083027f4b94dac17f958d2ee523a2206206994597c13d831ec7b844a9059cbb0000000000000000000000001a8c8adfbe1c59e8b58cc0d515f07b7225f51c720000000000000000000000000000000000000000000000000000000001312d00801ba03e141ea4233ec00bb3a80d7fea5f774b736772851b7bad18453d0f3c6097c42e9fa6eb47b6bead6a76d7db12809e2c916df999d7b99b613fcaa135abd8a0078e
```

### Approve

[](#approve)

Approve another address to spend tokens on your behalf:

```
use kornrunner\Ethereum\Token;
use kornrunner\Ethereum\Transaction;

$token = new Token;
$usdt  = new Token\USDT;

$spender = '1a8c8adfbe1c59e8b58cc0d515f07b7225f51c72';
$amount = 100;
$hexAmount = $token->hexAmount($usdt, $amount);

$data = $token->getApproveData($spender, $hexAmount);
// use $data with Transaction as shown above
```

### Burn

[](#burn)

Burn (destroy) tokens:

```
use kornrunner\Ethereum\Token;
use kornrunner\Ethereum\Transaction;

$token = new Token;
$usdt  = new Token\USDT;

$amount = 50;
$hexAmount = $token->hexAmount($usdt, $amount);

$data = $token->getBurnData($hexAmount);
// use $data with Transaction as shown above
```

### Mint

[](#mint)

Mint (create) new tokens to an address:

```
use kornrunner\Ethereum\Token;
use kornrunner\Ethereum\Transaction;

$token = new Token;
$usdt  = new Token\USDT;

$recipient = '1a8c8adfbe1c59e8b58cc0d515f07b7225f51c72';
$amount = 1000;
$hexAmount = $token->hexAmount($usdt, $amount);

$data = $token->getMintData($recipient, $hexAmount);
// use $data with Transaction as shown above
```

### TransferFrom

[](#transferfrom)

Transfer tokens from one address to another using allowance:

```
use kornrunner\Ethereum\Token;
use kornrunner\Ethereum\Transaction;

$token = new Token;
$usdt  = new Token\USDT;

$from = 'd9040b8a1f12a40511ac1f7b994a21dd08ceac20';
$to = '1a8c8adfbe1c59e8b58cc0d515f07b7225f51c72';
$amount = 50;
$hexAmount = $token->hexAmount($usdt, $amount);

$data = $token->getTransferFromData($from, $to, $hexAmount);
// use $data with Transaction as shown above
```

### Read-Only Functions

[](#read-only-functions)

For querying token information (generates ABI-encoded call data):

#### BalanceOf

[](#balanceof)

Get the token balance of an address:

```
use kornrunner\Ethereum\Token;

$token = new Token;
$address = '1a8c8adfbe1c59e8b58cc0d515f07b7225f51c72';

$data = $token->getBalanceOfData($address);
// 0x70a082310000000000000000000000001a8c8adfbe1c59e8b58cc0d515f07b7225f51c72
```

#### Allowance

[](#allowance)

Check how many tokens a spender is allowed to use:

```
use kornrunner\Ethereum\Token;

$token = new Token;
$owner = '1a8c8adfbe1c59e8b58cc0d515f07b7225f51c72';
$spender = 'd9040b8a1f12a40511ac1f7b994a21dd08ceac20';

$data = $token->getAllowanceData($owner, $spender);
// 0x...
```

#### TotalSupply

[](#totalsupply)

Get the total supply of tokens:

```
use kornrunner\Ethereum\Token;

$token = new Token;

$data = $token->getTotalSupplyData();
// 0x18160ddd
```

Crypto
------

[](#crypto)

[![Ethereum](https://user-images.githubusercontent.com/725986/61891022-0d0c7f00-af09-11e9-829f-096c039bbbfa.png) 0x9c7b7a00972121fb843af7af74526d7eb585b171](https://etherscan.io/address/0x9c7b7a00972121fb843af7af74526d7eb585b171 "Donate with Ethereum")

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance85

Actively maintained with recent releases

Popularity33

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.3% 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 ~1053 days

Total

3

Last Release

174d ago

PHP version history (3 changes)0.0.1PHP &gt;=7.2

0.1.0PHP &gt;=7.3

0.2.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/b3d0432439843a2a063fec06efcf774d2193469dd51d72cfbb6457f6301004cf?d=identicon)[kornrunner](/maintainers/kornrunner)

---

Top Contributors

[![kornrunner](https://avatars.githubusercontent.com/u/725986?v=4)](https://github.com/kornrunner "kornrunner (59 commits)")[![athamidn](https://avatars.githubusercontent.com/u/10267187?v=4)](https://github.com/athamidn "athamidn (1 commits)")

---

Tags

erc20ethethereumphp-ethereumrawtokentransactiontransactionethereumethofflinetx

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kornrunner-ethereum-token/health.svg)

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

###  Alternatives

[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

41.5k328.9k1](/packages/ccxt-ccxt)[kornrunner/ethereum-offline-raw-tx

Pure PHP Ethereum Offline Raw Transaction Signer

63192.1k22](/packages/kornrunner-ethereum-offline-raw-tx)[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)[furqansiddiqui/ethereum-rpc

Ethereum (geth) RPC client

2550.6k4](/packages/furqansiddiqui-ethereum-rpc)[kornrunner/solidity

Pure PHP implementation of Solidity

1940.5k11](/packages/kornrunner-solidity)

PHPackages © 2026

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