seregazhuk / etherscan-api
PHP client for the Etherscan API
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/seregazhuk/etherscan-api
Requires
- php: >=8.1
- php-http/client-common: ^2.0
- php-http/discovery: ^1.0
- php-http/guzzle7-adapter: ^1.1
- php-http/httplug: ^2.0
- phpseclib/phpseclib: ^3.0
- psr/http-client-implementation: ^1.0
- psr/http-factory-implementation: ^1.0
Requires (Dev)
- laravel/pint: ^1.20
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^10.1.0
- rector/rector: ^1.2
This package is auto-updated.
Last update: 2025-11-06 05:49:05 UTC
README
PHP client for Etherscan API (and its families like BscScan), with nearly full API bindings (accounts, transactions, tokens, contracts, blocks, stats) and full chains support.
Table of Contents
Installation
composer req seregazhuk/etherscan-api:dev-main
Quick Start
Register Etherscan account and create free API key.
$etherscan = new seregazhuk\EtherscanApi\EtherscanApi('your-api-key'); $currentBlock = $etherscan->proxy->getBlockNumber(); $transactionInfo = $etherscan->proxy->getTransactionByHash('0x136f818dfe87b367eee9890c162ef343dbd65e409aef102219a6091ba7e696d7'); $isConfirmed = $currentBlock ->subtract($transactionInfo->blockNumber) ->compare(new BigInteger('12')) >= 0; echo $isConfirmed ? 'Confirmed' : 'Not confirmed';
Use Binance Smart Chain (testnet):
$etherscanApi = new EtherscanApi('your-api-key', ChainId::BNB_SMART_CHAIN_TESTNET);
Available bindings
Accounts
Get Ether balance for a single address:
$balance = $etherscan->accounts->getBalance('0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae');
Get Ether balance for multiple addresses in a single call:
$balances = $etherscan->accounts->getBalances(['0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a', '0x63a9975ba31b0b9626b34300f7f627147df1f526']);
Get a list of 'Normal' transactions by address:
$transactions = $etherscan->accounts->getTransactions('0xc5102fE9359FD9a28f877a67E36B0F050d81a3CC');
Get a list of internal transactions by hash:
$transactions = $etherscan->accounts->getInternalTransactionsByHash('0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170');
Get internal transactions by block range:
$transactions = $this->accounts->getInternalTransactionsByBlockRange(13481773, 13491773);
Get ERC20 token transfers by address:
$erc20Events = $this->accounts->getErc20TokenTransferEvents('0x4e83362442b8d1bec281594cea3050c8eb01311c', '0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2');
Get ERC721 token transfers by address:
$erc721Events = $this->accounts->getErc721TokenTransferEvents('0x6975be450864c02b4613023c2152ee0743572325', '0x06012c8cf97bead5deae237070f9587f8e7a266d');
Get ERC1155 token transfers by address:
$erc1155Events = $this->accounts->getErc1155TokenTransferEvents('0x83f564d180b58ad9a02a449105568189ee7de8cb', '0x76be3b62873462d2142405439777e971754e8e77');