Download the PHP package jeavenguitar/web3php without Composer
On this page you can find all versions of the php package jeavenguitar/web3php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download jeavenguitar/web3php
More information about jeavenguitar/web3php
Files in jeavenguitar/web3php
Download jeavenguitar/web3php
More information about jeavenguitar/web3php
Files in jeavenguitar/web3php
Vendor jeavenguitar
Package web3php
Short Description PHP Ethereum/EVM toolkit in web3.js style: robust JSON-RPC client (multi-endpoint failover, retry, keep-alive), full ABI encoder/decoder (tuple/array/named outputs), contract calls and locally signed transactions (EIP-155 / EIP-1559).
License MIT
Package web3php
Short Description PHP Ethereum/EVM toolkit in web3.js style: robust JSON-RPC client (multi-endpoint failover, retry, keep-alive), full ABI encoder/decoder (tuple/array/named outputs), contract calls and locally signed transactions (EIP-155 / EIP-1559).
License MIT
Please rate this library. Is it a good library?
Informations about the package web3php
web3php
PHP 版 web3.js —— 面向以太坊 / EVM 兼容链(BSC、Arbitrum、Polygon、Base 等)的开发工具包。
核心目标:像 web3.js 一样好用,但把「RPC 节点抖动」当作一等公民来对待。
为什么再造一个轮子
社区常用的 web3 PHP 包在生产上反复被这些问题坑:
| 痛点 | 本包的做法 |
|---|---|
| 默认 1 秒超时,节点稍慢就抛异常 | 连接超时 15s + 总超时 60s 双层可配,防挂起也防误杀 |
| 每次请求重做 DNS/TCP/TLS 握手 | 按节点复用 keep-alive curl 句柄(公网节点单次握手 1~3 秒) |
| 节点偶发断连直接炸业务 | 陈旧长连接自动换句柄重试;失败按线性退避重试 |
| 单节点,挂了就全挂 | 多端点列表 + 自动故障转移,成功后粘住命中节点复用连接 |
| 空响应 / 网关 502 HTML 页静默失败 | 既无 result 也无 error、HTTP 非 200、非 JSON 一律按传输失败重试 |
tuple[] 解码崩溃、多值返回键名漂移 |
完整 ABI v2 编解码(嵌套 tuple / 定长与动态数组 / 任意组合),多值输出全命名时只返回字段名键,与链上结构一致 |
| 返回数据被截断时静默给出错值 | 解码前逐字节校验长度,截断即抛明确异常 |
| revert 只抛一个 "execution reverted" | 自动解出 Error(string) / Panic(uint256) 的人类可读原因 |
| 数值精度丢失(float/int 硬转) | 全链路 GMP:uint256 一律十进制字符串;编码侧拒绝浮点入参 |
交易签名依赖节点 personal_unlockAccount |
本地 secp256k1 签名(EIP-155 / EIP-1559),公网节点友好 |
安装
要求 PHP >= 8.1,扩展:curl、gmp、bcmath、json。
快速上手
初始化(推荐多节点)
链数据
大数(余额、gas、totalSupply…)统一返回十进制字符串,配合 bcmath / GMP 使用:
合约查询(eth_call + ABI 自动解码)
发送交易(本地签名 + 自动补费)
sendTransaction 缺省行为:nonce 取 pending、gasPrice 取 eth_gasPrice、gas 走 eth_estimateGas;
estimateGas 被 revert 时会抛出带人类可读原因的异常(Error(string) / Panic(uint256) 自动解码)。
批量查询
错误语义
- 传输层问题(连接失败 / 超时 / HTTP 非 200 / 非 JSON / 空响应)不直接抛:先在当前节点退避重试,耗尽后切换下一个节点,全部失败才抛
RpcException(message 汇总每个节点的失败原因)。 - RPC 业务错误(
execution reverted、参数错误等)不盲目重试(重试也必然失败),立即抛RpcException,带rpcCode/rpcData。 eth_getTransactionReceipt未上链返回null—— pending 不是错误。failover_error_codes:个别公共节点对特定查询返回错误而别的节点查得到(例如部分节点查久远回执返回-32602),把这类错误码配进来会自动换节点再查。
测试与验证
- PHPUnit 全离线:EIP-155 官方 worked example 逐字节复现、EIP-55 官方向量、RLP 官方向量、ERC20 选择子、ABI 全类型编解码往返、struct 数组长度语义、截断检测、EIP-1559 签名恢复闭环。
- 已对 BSC 主网实测:多节点故障转移、USDT 合约查询解码、批量查询、legacy 与 EIP-1559 交易签名(节点验签通过)。
目录结构
已知边界
fixed/ufixed类型未实现(极少有合约使用,遇到会抛出明确异常)。- 事件 ABI(topic 解码)尚未内置,
getLogs返回原始日志对象,可配合Abi手工解码。 - 只支持 HTTP(S) RPC 端点(WebSocket 不支持)。
License
MIT
All versions of web3php with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.1
ext-bcmath Version *
ext-curl Version *
ext-gmp Version *
ext-json Version *
kornrunner/keccak Version ^1.1
simplito/elliptic-php Version ^1.0.6
ext-bcmath Version *
ext-curl Version *
ext-gmp Version *
ext-json Version *
kornrunner/keccak Version ^1.1
simplito/elliptic-php Version ^1.0.6
The package jeavenguitar/web3php contains the following files
Loading the files please wait ...