PHPackages                             cqtop/eth-nano-erc20 - 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. cqtop/eth-nano-erc20

ActiveLibrary[API Development](/categories/api)

cqtop/eth-nano-erc20
====================

This library provides simple way to interact with Ethereum ERC20 token.

v1.0.2(4y ago)06PHPPHP &gt;=7.1

Since Dec 3Pushed 4y agoCompare

[ Source](https://github.com/cqtop/eth-nano-erc20)[ Packagist](https://packagist.org/packages/cqtop/eth-nano-erc20)[ RSS](/packages/cqtop-eth-nano-erc20/feed)WikiDiscussions main Synced 5d ago

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

Simple Ethereum ERC20 token php library
=======================================

[](#simple-ethereum-erc20-token-php-library)

This library provides simple way to interact with Ethereum ERC20 token.
By default, supports all ERC20 Standard functions (like balanceOf, transfer, transferFrom, approve, allowance, decimal, name, ...) also can be extends to support other contracts as well.

基于lessmore92/php-erc20库做了些修改
----------------------------

[](#基于lessmore92php-erc20库做了些修改)

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

[](#installation)

`composer require cqtop/eth-nano-erc20`

Usage
-----

[](#usage)

There are two ways to use:

#### 1- Make a new class for your token and specified their functions

[](#1--make-a-new-class-for-your-token-and-specified-their-functions)

#### 2- Use general class with all standard functions

[](#2--use-general-class-with-all-standard-functions)

See below to find out more

### 1-Make a new class for your token

[](#1-make-a-new-class-for-your-token)

Simply create a new class inherits from `\Lessmore92\Ethereum\Foundation\StandardERC20Token`

in below sample we create a new class for Tether (USDT)

```
class USDT extends \Lessmore92\Ethereum\Foundation\StandardERC20Token
{
    protected $contractAddress = "0xdac17f958d2ee523a2206206994597c13d831ec7";
}

```

Then for use create new instantiate from your class and

```
$tether = new USDT("https://mainnet.infura.io/v3/API_KEY");
var_dump($tether->name());
var_dump($tether->decimals());

```

### 2- Use general class

[](#2--use-general-class)

```
$token = new \Lessmore92\Ethereum\Token("0xdac17f958d2ee523a2206206994597c13d831ec7", "https://mainnet.infura.io/v3/API_KEY");
var_dump($token->name());

```

### Connection Timeout

[](#connection-timeout)

Connection timeout can be set by last parameter of token class

```
$timeout  = 3; //secs
$tether = new USDT("https://mainnet.infura.io/v3/API_KEY",$timeout);

```

OR

```
$timeout  = 3; //secs
$tether = new \Lessmore92\Ethereum\Token("0xdac17f958d2ee523a2206206994597c13d831ec7", "https://mainnet.infura.io/v3/API_KEY", $timeout);

```

Ethereum RPC Client
-------------------

[](#ethereum-rpc-client)

For connect to Ethereum blockchain you need an Ethereum node; [Infura](https://infura.io/) is a simple and fast solution, however you can launch you [Geth](https://geth.ethereum.org/) node

ERC20 Token `transferFrom`
--------------------------

[](#erc20-token-transferfrom)

ERC20 transaction fee needs to be paid in `ETH`. In some situation your app needs to pay this fee behalf of user.
Suppose, user A have a key pair (private, public) and all their transaction is limited to usdt. User A needs to send 10 usdt, but he/she haven't ETH to pay transaction fee.
In these cases your app should pay fee behalf of users.
`transferFrom` is a good solution in these cases.

`transferFrom` Flow:
--------------------

[](#transferfrom-flow)

1.First, Using `approve` method to grant permission to a delegator.
2.Then, Using `transferFrom` method to make transaction behalf of user.

*In Action*

```
$owner_private = '0xcf29c83a88e23d0b9e676beca426490bf79aca71e9d24f79a99d30c48292e1e3';
$owner_address = '0xA7e5F270c27E9d33911EE7D50D8E814f793d2760';

$myapp_private = '0xa6b6be193bfeac6160178ee6e1435609ae566a9054715e0802e4c3b39bb94e83';
$myapp_address = '0x8dC9b3c20795815aa063FEdBE8E564566CEc1893';

$to_address = '0x245013F05DdA116142Ca8db205ec4F8C780E3DcB';

//by this method we allow $myapp_address to send upto 99999 token behalf of $owner_address
$approve_tx    = $token->approve($owner_address, $myapp_address, 99999);
$approve_tx_id = $approve_tx->sign($owner_private)
                            ->send()
;

//the magic is here, $myapp_address send 10 tokens behalf of user and $myapp_address pay transaction fee
$transfer_tx    = $token->transferFrom($myapp_address, $owner_address, $to_address, 10);
$transfer_tx_id = $transfer_tx->sign($myapp_private)
                              ->send()
;

```

### `allowance` to check how much transferFrom remain

[](#allowance-to-check-how-much-transferfrom-remain)

`$remain = $token->allowance($owner_address, $myapp_address);`

*Notices:*
`approve` method not need to be used on every transaction.
To revoke `transferFrom` permission call `$token->approve($owner_address, $myapp_address, 0)` by amount `0`.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87% 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 ~242 days

Total

3

Last Release

1505d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f07bac3a9e1a4233b6712ddfc64e5a2a18fadab3ae966313ee19d1757ebc106?d=identicon)[cqtop](/maintainers/cqtop)

---

Top Contributors

[![lessmore92](https://avatars.githubusercontent.com/u/1258149?v=4)](https://github.com/lessmore92 "lessmore92 (20 commits)")[![cqtop](https://avatars.githubusercontent.com/u/18568769?v=4)](https://github.com/cqtop "cqtop (3 commits)")

### Embed Badge

![Health badge](/badges/cqtop-eth-nano-erc20/health.svg)

```
[![Health](https://phpackages.com/badges/cqtop-eth-nano-erc20/health.svg)](https://phpackages.com/packages/cqtop-eth-nano-erc20)
```

###  Alternatives

[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)[botman/driver-telegram

Telegram driver for BotMan

92437.3k6](/packages/botman-driver-telegram)

PHPackages © 2026

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