Download the PHP package cqtop/eth-nano-erc20 without Composer
On this page you can find all versions of the php package cqtop/eth-nano-erc20. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cqtop/eth-nano-erc20
More information about cqtop/eth-nano-erc20
Files in cqtop/eth-nano-erc20
Package eth-nano-erc20
Short Description This library provides simple way to interact with Ethereum ERC20 token.
License
Informations about the package eth-nano-erc20
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库做了些修改
Installation
composer require cqtop/eth-nano-erc20
Usage
There are two ways to use:
1- Make a new class for your token and specified their functions
2- Use general class with all standard functions
See below to find out more
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)
Then for use create new instantiate from your class and
2- Use general class
Connection Timeout
Connection timeout can be set by last parameter of token class
OR
Ethereum RPC Client
For connect to Ethereum blockchain you need an Ethereum node; Infura is a simple and fast solution, however you can launch you Geth node
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:
1.First, Using approve
method to grant permission to a delegator.
2.Then, Using transferFrom
method to make transaction behalf of user.
In Action
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
.
All versions of eth-nano-erc20 with dependencies
sc0vu/web3.php Version 0.1.4
web3p/ethereum-util Version 0.1.2
kornrunner/ethereum-offline-raw-tx Version 0.2.4