seregazhuk/etherscan-api
Composer 安装命令:
composer require seregazhuk/etherscan-api
包简介
PHP client for the Etherscan API
README 文档
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');
Contracts
$abi = $this->contracts->getAbi('0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413');
$sourceCode = $this->contracts->getSourceCode('0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413');
Proxy
$transactionInfo = $etherscan->proxy->getTransactionByHash('0x136f818dfe87b367eee9890c162ef343dbd65e409aef102219a6091ba7e696d7');
$currentBlock = $etherscan->proxy->getBlockNumber();
$blockInfo = $etherscan->proxy->getBlockByNumber('0x10d4f');
$result = $this->proxy->sendRawTransaction('0xf904808000831cfde080');
eth_getBlockTransactionCountByNumber:
$result = $this->proxy->getBlockTransactionCountByNumber('0x10FB78');
$result = $this->proxy->getTransactionCount('0x4bd5900Cb274ef15b153066D736bf3e83A9ba44e');
$result = $this->proxy->getTransactionReceipt('0xf75e354c5edc8efed9b59ee9f67a80845ade7d0c');
$result = $this->proxy->getGasPrice();
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-18