承接 furqansiddiqui/erc20-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

furqansiddiqui/erc20-php

Composer 安装命令:

composer require furqansiddiqui/erc20-php

包简介

Interact with any ERC20 standard/backward-compatible Ethereum token

README 文档

README

Tests MIT License

A PHP library for interacting with ERC-20 smart contracts on the Ethereum blockchain. This library uses the ethereum-php package for RPC communication and EVM interactions.

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

  • PHP: ^8.5
  • Extensions: openssl, gmp, bcmath

Installation

Install the package via Composer:

composer require furqansiddiqui/erc20-php

Usage

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

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

$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

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

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

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

composer install
./vendor/bin/phpunit

License

This package is open-source software licensed under the MIT license.

furqansiddiqui/erc20-php 适用场景与选型建议

furqansiddiqui/erc20-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 67.62k 次下载、GitHub Stars 达 164, 最近一次更新时间为 2018 年 04 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「ethereum」 「eth」 「geth」 「ethereum-go」 「erc20」 「erc223」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 furqansiddiqui/erc20-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 furqansiddiqui/erc20-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 furqansiddiqui/erc20-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 67.62k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 167
  • 点击次数: 29
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

  • Stars: 164
  • Watchers: 20
  • Forks: 96
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-17