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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
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

[PHP]() [License]()

中文文档

Features

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:

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
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package phpmac/ethers-php contains the following files

Loading the files please wait ...