{"id":15025499,"url":"https://github.com/lessmore92/php-erc20","last_synced_at":"2026-03-14T17:45:03.306Z","repository":{"id":39983831,"uuid":"314947003","full_name":"lessmore92/php-erc20","owner":"lessmore92","description":"The simple way to interact with Ethereum ERC20 token.","archived":false,"fork":false,"pushed_at":"2021-11-13T09:15:40.000Z","size":35,"stargazers_count":25,"open_issues_count":2,"forks_count":25,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-09T20:03:08.814Z","etag":null,"topics":["erc20","erc20-tokens","erc20token","ethereum","pay","php","php71","transaction","transferfrom","usdt"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lessmore92.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-22T02:53:31.000Z","updated_at":"2024-12-26T14:37:39.000Z","dependencies_parsed_at":"2022-06-26T01:40:12.201Z","dependency_job_id":null,"html_url":"https://github.com/lessmore92/php-erc20","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lessmore92%2Fphp-erc20","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lessmore92%2Fphp-erc20/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lessmore92%2Fphp-erc20/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lessmore92%2Fphp-erc20/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lessmore92","download_url":"https://codeload.github.com/lessmore92/php-erc20/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103864,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["erc20","erc20-tokens","erc20token","ethereum","pay","php","php71","transaction","transferfrom","usdt"],"created_at":"2024-09-24T20:02:28.068Z","updated_at":"2026-03-14T17:45:03.275Z","avatar_url":"https://github.com/lessmore92.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple Ethereum ERC20 token php library\n\nThis library provides simple way to interact with Ethereum ERC20 token.  \nBy default, supports all ERC20 Standard functions (like balanceOf, transfer, transferFrom, approve, allowance, decimal, name, ...) also can be extends to support other contracts as well.\n\n## Installation\n`composer require lessmore92/php-erc20`\n\n## Usage\nThere are two ways to use:\n#### 1- Make a new class for your token and specified their functions\n#### 2- Use general class with all standard functions\n\nSee below to find out more\n\n\n### 1-Make a new class for your token\nSimply create a new class inherits from `\\Lessmore92\\Ethereum\\Foundation\\StandardERC20Token`\n\nin below sample we create a new class for Tether (USDT)\n```\nclass USDT extends \\Lessmore92\\Ethereum\\Foundation\\StandardERC20Token \n{\n    protected $contractAddress = \"0xdac17f958d2ee523a2206206994597c13d831ec7\";  \n}\n```\nThen for use create new instantiate from your class and\n\n```\n$tether = new USDT(\"https://mainnet.infura.io/v3/API_KEY\");\nvar_dump($tether-\u003ename());\nvar_dump($tether-\u003edecimals());\n```\n\n### 2- Use general class\n\n```\n$token = new \\Lessmore92\\Ethereum\\Token(\"0xdac17f958d2ee523a2206206994597c13d831ec7\", \"https://mainnet.infura.io/v3/API_KEY\");\nvar_dump($token-\u003ename());\n```\n\n\n### Connection Timeout\n\nConnection timeout can be set by last parameter of token class\n\n```\n$timeout  = 3; //secs\n$tether = new USDT(\"https://mainnet.infura.io/v3/API_KEY\",$timeout);\n```\nOR\n```\n$timeout  = 3; //secs\n$tether = new \\Lessmore92\\Ethereum\\Token(\"0xdac17f958d2ee523a2206206994597c13d831ec7\", \"https://mainnet.infura.io/v3/API_KEY\", $timeout);\n```\n\n## Ethereum RPC Client\nFor 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\n\n\n## ERC20 Token `transferFrom`\nERC20 transaction fee needs to be paid in `ETH`. In some situation your app needs to pay this fee behalf of user.  \nSuppose, 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.  \nIn these cases your app should pay fee behalf of users.      \n`transferFrom` is a good solution in these cases.\n\n\n## `transferFrom` Flow:\n1.First, Using `approve` method to grant permission to a delegator.  \n2.Then, Using `transferFrom` method to make transaction behalf of user. \n\n*In Action*\n```\n$owner_private = '0xcf29c83a88e23d0b9e676beca426490bf79aca71e9d24f79a99d30c48292e1e3';\n$owner_address = '0xA7e5F270c27E9d33911EE7D50D8E814f793d2760';\n\n$myapp_private = '0xa6b6be193bfeac6160178ee6e1435609ae566a9054715e0802e4c3b39bb94e83';\n$myapp_address = '0x8dC9b3c20795815aa063FEdBE8E564566CEc1893';\n\n$to_address = '0x245013F05DdA116142Ca8db205ec4F8C780E3DcB';\n\n//by this method we allow $myapp_address to send upto 99999 token behalf of $owner_address\n$approve_tx    = $token-\u003eapprove($owner_address, $myapp_address, 99999);\n$approve_tx_id = $approve_tx-\u003esign($owner_private)\n                            -\u003esend()\n;\n\n\n//the magic is here, $myapp_address send 10 tokens behalf of user and $myapp_address pay transaction fee\n$transfer_tx    = $token-\u003etransferFrom($myapp_address, $owner_address, $to_address, 10);\n$transfer_tx_id = $transfer_tx-\u003esign($myapp_private)\n                              -\u003esend()\n;\n\n```\n\n### `allowance` to check how much transferFrom remain\n\n`$remain = $token-\u003eallowance($owner_address, $myapp_address);`\n\n*Notices:*  \n`approve` method not need to be used on every transaction.  \nTo revoke `transferFrom` permission call `$token-\u003eapprove($owner_address, $myapp_address, 0)` by amount `0`.  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flessmore92%2Fphp-erc20","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flessmore92%2Fphp-erc20","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flessmore92%2Fphp-erc20/lists"}