Download the PHP package phpmac/ethers-php without Composer
On this page you can find all versions of the php package phpmac/ethers-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download phpmac/ethers-php
More information about phpmac/ethers-php
Files in phpmac/ethers-php
Download phpmac/ethers-php
More information about phpmac/ethers-php
Files in phpmac/ethers-php
Vendor phpmac
Package ethers-php
Short Description PHP SDK for Ethereum, inspired by ethers.js v6
License MIT
Package ethers-php
Short Description PHP SDK for Ethereum, inspired by ethers.js v6
License MIT
Please rate this library. Is it a good library?
Informations about the package ethers-php
ethers-php
PHP SDK for Ethereum, inspired by ethers.js v6
[]()
[
]()
中文文档
Features
- Human-readable ABI support (fully compatible with ethers.js v6)
- Complete wallet functionality (creation, signing, sending transactions)
- Contract interaction (calling, deployment, event listening)
- Utility functions (unit conversion, address validation, hashing)
Installation
Quick Start
Provider
Wallet
Contract
Supports two ABI formats:
1. Human-readable ABI (recommended, same as ethers.js)
2. JSON ABI format
Write operations
ContractFunction style calls
IDE Support (Optional)
Contract uses PHP's __call magic method for dynamic function calls. This may cause IDE warnings like "Method not defined".
Solution 1: Use call() method
Solution 2: Create a typed subclass with PHPDoc
See CLAUDE.md for more details.
Multicall (Batch Requests)
Use JSON-RPC 2.0 batch requests to combine multiple contract calls into a single HTTP request.
Key features:
- Single HTTP request for multiple data reads
- Results maintain call order
- Support for methods with arguments (e.g.,
balanceOf(address))
See examples/multicall_demo.php for full example.
Deploy Contract (ContractFactory)
Parse ABI (Interface)
Utility Functions
API Reference
JsonRpcProvider
| Method | Description |
|---|---|
getChainId() |
Get chain ID |
getNetwork() |
Get network info |
getBlockNumber() |
Get current block number |
getBalance($address) |
Get account balance |
getTransactionCount($address) |
Get transaction count (nonce) |
getGasPrice() |
Get gas price |
getFeeData() |
Get fee data (EIP-1559) |
estimateGas($tx) |
Estimate gas |
call($tx) |
Read-only call |
sendRawTransaction($signedTx) |
Send signed transaction |
getTransaction($hash) |
Get transaction info |
getTransactionReceipt($hash) |
Get transaction receipt |
waitForTransaction($hash) |
Wait for transaction confirmation |
getBlock($blockHashOrNumber) |
Get block info |
getLogs($filter) |
Get event logs |
Wallet
| Method | Description |
|---|---|
getAddress() |
Get address |
getPrivateKey() |
Get private key |
connect($provider) |
Connect to Provider |
getBalance() |
Get balance |
getNonce() |
Get nonce |
signMessage($message) |
Sign message |
signTransaction($tx) |
Sign transaction |
sendTransaction($tx) |
Send transaction |
createRandom() |
Create random wallet |
Contract
| Method | Description |
|---|---|
call($method, $args) |
Read-only call |
send($method, $args) |
Send transaction |
staticCall($method, $args) |
Static call |
estimateGas($method, $args) |
Estimate gas |
encodeFunction($method, $args) |
Encode function call |
queryFilter($eventName, $filter) |
Query event logs |
multicall($calls) |
Batch requests (JSON-RPC 2.0) |
Comparison with ethers.js v6
| ethers.js v6 | ethers-php |
|---|---|
new ethers.JsonRpcProvider(url) |
new JsonRpcProvider($url) |
new ethers.Wallet(key, provider) |
new Wallet($key, $provider) |
new ethers.Contract(addr, abi, runner) |
new Contract($addr, $abi, $runner) |
new ethers.ContractFactory(abi, bytecode, signer) |
new ContractFactory($abi, $bytecode, $signer) |
ethers.parseEther('1.0') |
Ethers::parseEther('1.0') |
ethers.Interface.from(abi) |
Interface_::from($abi) |
contract.target |
$contract->target |
contract.balanceOf(addr) |
$contract->balanceOf($addr) |
contract.transfer.staticCall(to, amount) |
$contract->transfer->staticCall([$to, $amount]) |
contract.transfer.estimateGas(to, amount) |
$contract->transfer->estimateGas([$to, $amount]) |
contract.getFunction('transfer') |
$contract->getFunction('transfer') |
factory.deploy(arg1, arg2) |
$factory->deploy($arg1, $arg2) |
contract.waitForDeployment() |
$contract->waitForDeployment() |
ABI Format Comparison
All versions of ethers-php with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.2
ext-bcmath Version *
ext-gmp Version *
guzzlehttp/guzzle Version ^7.0
kornrunner/keccak Version ^1.1
kornrunner/secp256k1 Version ^0.3.0
simplito/elliptic-php Version ^1.0
textalk/websocket Version ^1.5
ext-bcmath Version *
ext-gmp Version *
guzzlehttp/guzzle Version ^7.0
kornrunner/keccak Version ^1.1
kornrunner/secp256k1 Version ^0.3.0
simplito/elliptic-php Version ^1.0
textalk/websocket Version ^1.5
The package phpmac/ethers-php contains the following files
Loading the files please wait ...