比特派钱包下载安卓版|etherscan api

作者: 比特派钱包下载安卓版
2024-03-17 03:59:08

Etherscan 使用说明 — Etherscan API 中文文档 — 深入浅出区块链

Etherscan 使用说明 — Etherscan API 中文文档 — 深入浅出区块链

深入浅出区块链

Etherscan API 中文文档

Latest

Etherscan APIs 手册

Etherscan API 约定

包含模块

参数

测试网络接口Host

账号(Account)

获取单个账号余额

获取多个账号余额

获取地址(普通)交易列表

获取地址”内部”交易列表

获取地址ERC20转账交易列表

获取地址所挖区块列表

智能合约(Contracts)

获取已经验证代码合约的ABI

获取已经验证代码合约的源码

[BETA] 验证源代码

交易(Transaction)

[BETA] 检查合约执行状态

[BETA] 检查交易收据状态

区块(Blocks)

通过区块号获取块及叔块奖励

事件日志 (Event Logs)

通过指定区块获取日志

通过指定区块获取日志

节点代理(Geth/Parity Proxy) APIs

获取最近区块号

通过区块号查询区块信息

通过区块号查询叔块信息

通过区块号查询交易数量

通过哈希查询交易信息

通过区块号查询交易信息

通过地址的交易数量

发送原始交易

通过哈希查询交易收据

执行消息调用

获取地址代码

获取地址上某个位置的值 (体验功能)

获取当前gas Price

测量gas Limit

代币信息 Token

通过合约地址获取ERC20 Token总供应量

获取ERC20代币余额

常规状态数据(General Stats)

获取以太总供应量

获取以太最新价格

获取节点大小(Size)

第三方工具(Utils)

Python API 封装 (by corpetty)

node API 封装 ( by Sebastian Schürmann)

Go API

Php 接口

帮助手册-用Markdown写Sphinx

Markdown转reST

数学公式

参考

相关文档

Solidity 中文文档

ethers.js 中文文档

Web3.js 中文文档

Etherscan API 中文文档

Docs »

Etherscan 使用说明

Edit on GitHub

Etherscan 使用说明¶

本文档是基于 官方最新文档 由 深入浅出区块链 社区成员整理、翻译及校队,我们虽力求准确,但如您发现纰漏,欢迎到 GitHub 提Issues 指正。

尊重汗水,需转载请联系微信:xlbxiong 获取授权。

简介¶

Etherscan 是以太坊上应用最广泛的区块链浏览器,也提供 API 服务。

我们知道以太坊节点提供的API功能有限,尤其是需要一些多个区块相关的数据时,必须要依靠Etherscan API这样的服务。

Etherscan API是社区提供的服务,仅支持每秒 5 个GET或POST请求,可以在这个地址 API-Keys 申请一个Key。

如果在商业或站点中使用,应该表明服务由 Etherscan.io API 提供支持。

Etherscan APIs 手册

Etherscan API 约定

包含模块

参数

测试网络接口Host

账号(Account)

获取单个账号余额

获取多个账号余额

获取地址(普通)交易列表

获取地址”内部”交易列表

获取地址ERC20转账交易列表

获取地址所挖区块列表

智能合约(Contracts)

获取已经验证代码合约的ABI

获取已经验证代码合约的源码

[BETA] 验证源代码

交易(Transaction)

[BETA] 检查合约执行状态

[BETA] 检查交易收据状态

区块(Blocks)

通过区块号获取块及叔块奖励

事件日志 (Event Logs)

通过指定区块获取日志

通过指定区块获取日志

节点代理(Geth/Parity Proxy) APIs

获取最近区块号

通过区块号查询区块信息

通过区块号查询叔块信息

通过区块号查询交易数量

通过哈希查询交易信息

通过区块号查询交易信息

通过地址的交易数量

发送原始交易

通过哈希查询交易收据

执行消息调用

获取地址代码

获取地址上某个位置的值 (体验功能)

获取当前gas Price

测量gas Limit

代币信息 Token

通过合约地址获取ERC20 Token总供应量

获取ERC20代币余额

常规状态数据(General Stats)

获取以太总供应量

获取以太最新价格

获取节点大小(Size)

第三方工具(Utils)

Python API 封装 (by corpetty)

node API 封装 ( by Sebastian Schürmann)

Go API

Php 接口

帮助手册-用Markdown写Sphinx

Markdown转reST

数学公式

参考

Next

© Copyright 2019, 深入浅出区块链

最后更新于 2019/5月/10.

Built with Sphinx using a theme provided by Read the Docs.

Etherscan Information Center | Using the API Service

rscan Information Center | Using the API ServiceInformation Center

Newsletter

Glossary

Go to EtherscanSearchHomeDeveloperUsing the API ServiceUsing the API ServiceThe Etherscan API empowers you to tap into a treasure trove of information about Ethereum. With the Etherscan API, you can fetch details about transactions, check wallet balances, and token supply — all in a customized way that caters to your specific needs, without the need to juggle multiple Etherscan browser tabs.

For instance, if you aim to monitor ERC-20 token transactions for a particular address, simply call the Get a list of 'ERC-20 - Token Transfer Events' by Address endpoint and customize it to display only the columns that matter to you. Moreover, the values are updated programmatically every second, up to 30 calls per second.

For those new to using APIs, here's a simple guide you can follow to get a feel for integrating API data into Google Sheets:

Integrating Google Sheets

Click image to view a simple API integration on Google SheetsSetting Up Your Free API Key

Once logged into your Etherscan account, navigate to etherscan.io/myapikey in your profile. Click on the "+ Add" button to create a new API key.

Each account is limited to 3 API keys

Free API keys are limited to 5 calls/second

Once you've created your API key, you can use it to call the free API endpoints and power your dapps with rich data.

You can also view your API usage statistics, including a breakdown of the module and action called using a particular API key:

View your API usage statistics

Source attribution via a link back or mention that your app is "Powered by Etherscan.io APIs" is required except for personal/private usage.

Refer here for API key rate limit & expected error returns.

API Pro Subscription

With an API Pro subscription, you have access to much richer onchain data and higher call limits. For example, you could:

Get Address ERC-20 Token Holding

Get Historical ERC-20-Token Account Balance for TokenContractAddress by BlockNo

Learn more:

API Pro endpoints

API Pro plans

Interested to Upgrade your API plan? Here's how:

Simply click on "Upgrade Plan ->" or head to etherscan.io/apis and choose a plan that suits your needs (an annual subscription saves you more!).

Then, on the checkout page, you can confirm the total amount you need to pay. Optionally, you can apply a promotion code.

(Note: Promotion code shown in the screenshot is for demonstration purposes only)

Then, depending on your card provider, a pop-up window will appear for you to confirm this payment.

*Please make sure not to close the browser after payment. The system will prompt a form for you to provide a registered username and email after payment is successful.

Once you're satisfied with your purchase, you'll see your plan summary on your dashboard, including the next renewal date.

Here, you can manage your plan, including adding payment methods, upgrading, and cancelling your plan.

Contact Us

If you encounter any issues while setting up your API key or upgrading your API plan, please feel free to contact us!

Frequently Asked Questions

What are the Payment Options available?

We accept major credit cards that are supported by Stripe.

What is your refund policy?

Payments made are non-refundable and we do not provide refunds or credits for any services already paid for.

When will Account Activation occur?

API Pro accounts will be activated within 24 hours after username and email has been received.

*Please make sure not to close the browser after payment. The system will prompt a form for you to provide a registered username and email after payment is successful.

How does Renewal work for API Pro accounts?

Stripe billing is auto-renewed by default. Unless you cancel your subscription plan before your billing date, you authorise us to automatically charge the subscription fee for the next billing cycle to your account.

The billing portal will provide an auto-billing date where information such as a renewal subscription term that will begin automatically after the initial subscription term or another renewal term will be reflected in your account unless you cancel or terminate prior to the commencement of new term.

Kindly contact us should you wish to turn the auto-renewal option off.

Teck Yuan Lee

Last updated: 11th January 2024Related ArticlesVerifying ContractsAPI Key Rate Limit & ErrorsHow to determine the correct constructor argument during contract source code verification on EtherscanEtherscan Developer API Key 🔑Contract Verification - Constructor ArgumentsContract Troubleshooting - Unable to Verify Contract SourceStill Have Questions?Contact UsOur support team's ready for your questions, anytime.Priority SupportA Paid Service for priority handling of your needs and queries.Developer DocsIn-depth explanations on technical issues faced by developers.© 2023 Etherscan Information Cen

Sample API Calls

Sample API Calls

Account APIs

Get Ether Balance for a single Address

/api?module=account&action=balance&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&tag=latest&apikey=YourApiKeyToken

Get Historical Ether Balance for a single Address By BlockNo

/api?module=account&action=balancehistory&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&blockno=8000000&apikey=YourApiKeyToken

Get Ether Balance for multiple Addresses in a single call

/api?module=account&action=balancemulti&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a,0x63a9975ba31b0b9626b34300f7f627147df1f526,0x198ef1ec325a96cc354c7266a038be8b5c558f67&tag=latest&apikey=YourApiKeyToken

Separate addresses by comma, up to a maxium of 20 accounts in a single batch

Get a list of 'Normal' Transactions By Address

[Optional Parameters] startblock: starting blockNo to retrieve results, endblock: ending blockNo to retrieve results

/api?module=account&action=txlist&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&startblock=0&endblock=99999999&sort=asc&apikey=YourApiKeyToken

(Returned 'isError' values: 0=No Error, 1=Got Error)

(Returns up to a maximum of the last 10000 transactions only)

Or

/api?module=account&action=txlist&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&startblock=0&endblock=99999999&page=1&offset=10&sort=asc&apikey=YourApiKeyToken

(To get paginated results use page= and offset=)

Get a list of 'Internal' Transactions by Address

[Optional Parameters] startblock: starting blockNo to retrieve results, endblock: ending blockNo to retrieve results

/api?module=account&action=txlistinternal&address=0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3&startblock=0&endblock=2702578&sort=asc&apikey=YourApiKeyToken

(Returned 'isError' values: 0=No Error, 1=Got Error)

(Returns up to a maximum of the last 10000 transactions only)

Or

/api?module=account&action=txlistinternal&address=0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3&startblock=0&endblock=2702578&page=1&offset=10&sort=asc&apikey=YourApiKeyToken

(To get paginated results use page= and offset=)

Get "Internal Transactions" by Transaction Hash

/api?module=account&action=txlistinternal&txhash=0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170&apikey=YourApiKeyToken

(Returned 'isError' values: 0=Ok, 1=Rejected/Cancelled)

(Returns up to a maximum of the last 10000 transactions only)

Get "Internal Transactions" by Block Range

/api?module=account&action=txlistinternal&startblock=0&endblock=2702578&page=1&offset=10&sort=asc&apikey=YourApiKeyToken

(Returns up to a maximum of the last 10000 transactions only)

Get a list of "ERC20 - Token Transfer Events" by Address

[Optional Parameters] startblock: starting blockNo to retrieve results, endblock: ending blockNo to retrieve results

/api?module=account&action=tokentx&address=0x4e83362442b8d1bec281594cea3050c8eb01311c&startblock=0&endblock=999999999&sort=asc&apikey=YourApiKeyToken

(Returns up to a maximum of the last 10000 transactions only)

Or

/api?module=account&action=tokentx&contractaddress=0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2&page=1&offset=100&sort=asc&apikey=YourApiKeyToken

(To get paginated results use page= and offset=)

Or

/api?module=account&action=tokentx&contractaddress=0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2&address=0x4e83362442b8d1bec281594cea3050c8eb01311c&page=1&offset=100&sort=asc&apikey=YourApiKeyToken

(To get transfer events for a specific token contract, include the contractaddress parameter)

Get a list of "ERC721 - Token Transfer Events" by Address

[Optional Parameters] startblock: starting blockNo to retrieve results, endblock: ending blockNo to retrieve results

/api?module=account&action=tokennfttx&address=0x6975be450864c02b4613023c2152ee0743572325&startblock=0&endblock=999999999&sort=asc&apikey=YourApiKeyToken

(Returns up to a maximum of the last 10000 transactions only)

Or

/api?module=account&action=tokennfttx&contractaddress=0x06012c8cf97bead5deae237070f9587f8e7a266d&page=1&offset=100&sort=asc&apikey=YourApiKeyToken

(To get paginated results use page= and offset=)

Or

/api?module=account&action=tokennfttx&contractaddress=0x06012c8cf97bead5deae237070f9587f8e7a266d&address=0x6975be450864c02b4613023c2152ee0743572325&page=1&offset=100&sort=asc&apikey=YourApiKeyToken

(To get transfer events for a specific token contract, include the contractaddress parameter)

Get a list of "ERC1155 - Token Transfer Events" by Address

[Optional Parameters] startblock: starting blockNo to retrieve results, endblock: ending blockNo to retrieve results

/api?module=account&action=token1155tx&address=0x72855c26ee72bbe2db66a9a50eae750bd0f5bc88&startblock=0&endblock=999999999&sort=asc&apikey=YourApiKeyToken

(Returns up to a maximum of the last 10000 transactions only)

Or

/api?module=account&action=token1155tx&contractaddress=0x06012c8cf97bead5deae237070f9587f8e7a266d&page=1&offset=100&sort=asc&apikey=YourApiKeyToken

(To get paginated results use page= and offset=)

Or

/api?module=account&action=token1155tx&contractaddress=0x06012c8cf97bead5deae237070f9587f8e7a266d&address=0xba52c75764d6f594735dc735be7f1830cdf58ddf&page=1&offset=100&sort=asc&apikey=YourApiKeyToken

(To get transfer events for a specific token contract, include the contractaddress parameter)

Get list of Blocks Mined by Address

/api?module=account&action=getminedblocks&address=0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b&blocktype=blocks&apikey=YourApiKeyToken

Or

/api?module=account&action=getminedblocks&address=0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b&blocktype=blocks&page=1&offset=10&apikey=YourApiKeyToken

(To get paginated results use page= and offset=)

** type = blocks (full blocks only) or uncles (uncle blocks only)

Contract APIs

Get Contract ABI for Verified Contract Source Codes

/api?module=contract&action=getabi&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=YourApiKeyToken

A simple sample for retrieving the contractABI using Web3.js and Jquery to interact with a contract

var Web3 = require('web3');

var web3 = new Web3(new Web3.providers.HttpProvider());

var version = web3.version.api;

$.getJSON('http://api.etherscan.io/api?module=contract&action=getabi&address=0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359', function (data) {

var contractABI = "";

contractABI = JSON.parse(data.result);

if (contractABI != ''){

var MyContract = web3.eth.contract(contractABI);

var myContractInstance = MyContract.at("0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359");

var result = myContractInstance.memberId("0xfe8ad7dd2f564a877cc23feea6c0a9cc2e783715");

console.log("result1 : " + result);

var result = myContractInstance.members(1);

console.log("result2 : " + result);

} else {

console.log("Error" );

}

});

Get Contract Source Code for Verified Contract Source Codes

1. /api?module=contract&action=getsourcecode&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=YourApiKeyToken (replace the address parameter with the actual contract address)

2. You can also download a CSV list of Verified contract addresses of which the code publishers have provided a corresponding Open Source license for re-distribution

3. Terms of usage: Please see the usage terms policy

Verify Source Code (beta)

1. Requires a valid Etherscan APIkey, will reject if otherwise

2. Current daily limit of 100 submissions per day per user (subject to change)

3. Only supports HTTP post due to max transfer size limitations for http get

4. Supports up to 10 different library pairs

5. Contracts that use "imports" will need to have the code concatenated into one file as we do not support "imports" in separate files. You can try using the Blockcat solidity-flattener or SolidityFlattery

6. List of supported solc versions, only solc version v0.4.11 and above is supported. Ex. v0.4.25+commit.59dbf8f1

7. Upon successful submission you will receive a GUID (50 characters) as a receipt.

8. You may use this GUID to track the status of your submission

9. Verified Source Codes will be displayed at contractsVerified

See Demo Source Verification Submission Code at Source Code Verification Sample

Source Code Submission Gist (returns a guid as part of the result upon success):

//Submit Source Code for Verification

$.ajax({

type: "POST", //Only POST supported

url: "/api", //Set to the correct API url for Other Networks

data: {

apikey: $('#apikey').val(), //A valid API-Key is required

module: 'contract', //Do not change

action: 'verifysourcecode', //Do not change

contractaddress: $('#contractaddress').val(), //Contract Address starts with 0x...

sourceCode: $('#sourceCode').val(), //Contract Source Code (Flattened if necessary)

codeformat: $('#codeformat').val(), //solidity-single-file (default) or solidity-standard-json-input (for std-input-json-format support

contractname: $('#contractname').val(), //ContractName (if codeformat=solidity-standard-json-input, then enter contractname as ex: erc20.sol:erc20)

compilerversion: $('#compilerversion').val(), // see http://etherscan.io/solcversions for list of support versions

optimizationUsed: $('#optimizationUsed').val(), //0 = No Optimization, 1 = Optimization used (applicable when codeformat=solidity-single-file)

runs: 200, //set to 200 as default unless otherwise (applicable when codeformat=solidity-single-file)

constructorArguements: $('#constructorArguements').val(), //if applicable

evmversion: $('#evmVersion').val(), //leave blank for compiler default, homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg, istanbul (applicable when codeformat=solidity-single-file)

licenseType: $('#licenseType').val(), //Valid codes 1-12 where 1=No License .. 12=Apache 2.0, see https://etherscan.io/contract-license-types

libraryname1: $('#libraryname1').val(), //if applicable, a matching pair with libraryaddress1 required

libraryaddress1: $('#libraryaddress1').val(), //if applicable, a matching pair with libraryname1 required

libraryname2: $('#libraryname2').val(), //if applicable, matching pair required

libraryaddress2: $('#libraryaddress2').val(), //if applicable, matching pair required

libraryname3: $('#libraryname3').val(), //if applicable, matching pair required

libraryaddress3: $('#libraryaddress3').val(), //if applicable, matching pair required

libraryname4: $('#libraryname4').val(), //if applicable, matching pair required

libraryaddress4: $('#libraryaddress4').val(), //if applicable, matching pair required

libraryname5: $('#libraryname5').val(), //if applicable, matching pair required

libraryaddress5: $('#libraryaddress5').val(), //if applicable, matching pair required

libraryname6: $('#libraryname6').val(), //if applicable, matching pair required

libraryaddress6: $('#libraryaddress6').val(), //if applicable, matching pair required

libraryname7: $('#libraryname7').val(), //if applicable, matching pair required

libraryaddress7: $('#libraryaddress7').val(), //if applicable, matching pair required

libraryname8: $('#libraryname8').val(), //if applicable, matching pair required

libraryaddress8: $('#libraryaddress8').val(), //if applicable, matching pair required

libraryname9: $('#libraryname9').val(), //if applicable, matching pair required

libraryaddress9: $('#libraryaddress9').val(), //if applicable, matching pair required

libraryname10: $('#libraryname10').val(), //if applicable, matching pair required

libraryaddress10: $('#libraryaddress10').val() //if applicable, matching pair required

},

success: function (result) {

console.log(result);

if (result.status == "1") {

//1 = submission success, use the guid returned (result.result) to check the status of your submission.

// Average time of processing is 30-60 seconds

document.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result;

// result.result is the GUID receipt for the submission, you can use this guid for checking the verification status

} else {

//0 = error

document.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result;

}

console.log("status : " + result.status);

console.log("result : " + result.result);

},

error: function (result) {

console.log("error!");

document.getElementById("postresult").innerHTML = "Unexpected Error"

}

});

Check Source code verification submission status:

//Check Source Code Verification Status

$.ajax({

type: "GET",

url: "/api",

data: {

guid: 'ezq878u486pzijkvvmerl6a9mzwhv6sefgvqi5tkwceejc7tvn', //Replace with your Source Code GUID receipt above

module: "contract",

action: "checkverifystatus"

},

success: function (result) {

console.log("status : " + result.status); //0=Error, 1=Pass

console.log("message : " + result.message); //OK, NOTOK

console.log("result : " + result.result); //result explanation

$('#guidstatus').html(">> " + result.result);

},

error: function (result) {

alert('error');

}

});

Transaction APIs

Check Contract Execution Status (if there was an error during contract execution)

Note: isError":"0" = Pass , isError":"1" = Error during Contract Execution

/api?module=transaction&action=getstatus&txhash=0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a&apikey=YourApiKeyToken

Check Transaction Receipt Status (Only applicable for Post Byzantium fork transactions)

Note: status: 0 = Fail, 1 = Pass. Will return null/empty value for pre-byzantium fork

/api?module=transaction&action=gettxreceiptstatus&txhash=0x513c1ba0bebf66436b5fed86ab668452b7805593c05073eb2d51d3a52f480a76&apikey=YourApiKeyToken

Blocks APIs

Get Block And Uncle Rewards by BlockNo

/api?module=block&action=getblockreward&blockno=2165403&apikey=YourApiKeyToken

Get Estimated Block Countdown Time by BlockNo

/api?module=block&action=getblockcountdown&blockno=9100000&apikey=YourApiKeyToken

Get Block Number by Timestamp

[Parameters] timestamp format: Unix timestamp (supports Unix timestamps in seconds), closest value: 'before' or 'after'

/api?module=block&action=getblocknobytime×tamp=1578638524&closest=before&apikey=YourApiKeyToken

Event Logs

The Event Log API was designed to provide an alternative to the native eth_getLogs. Below are the list of supported filter parameters:

. fromBlock, toBlock, address

. topic0, topic1, topic2, topic3 (32 Bytes per topic)

. topic0_1_opr (and|or between topic0 & topic1), topic1_2_opr (and|or between topic1 & topic2), topic2_3_opr (and|or between topic2 & topic3), topic0_2_opr (and|or between topic0 & topic2), topic0_3_opr (and|or between topic0 & topic3), topic1_3_opr (and|or between topic1 & topic3)

- FromBlock & ToBlock accepts the blocknumber (integer, NOT hex) or 'latest' (earliest & pending is NOT supported yet)

- Topic Operator (opr) choices are either 'and' or 'or' and are restricted to the above choices only

- FromBlock & ToBlock parameters are required

- An address and/or topic(X) parameters are required, when multiple topic(X) parameters are used the topicX_X_opr (and|or operator) is also required

- For performance & security considerations, only the first 1000 results are return. So please narrow down the filter parameters

Here are some examples of how this filter maybe used:

Get Event Logs from block number 379224 to 'latest' Block, where log address = 0x33990122638b9132ca29c723bdf037f1a891a70c and topic[0] = 0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545

/api?module=logs&action=getLogs&fromBlock=379224&toBlock=latest&address=0x33990122638b9132ca29c723bdf037f1a891a70c&topic0=0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545&apikey=YourApiKeyToken

Get Event Logs from block number 379224 to block 400000 , where log address = 0x33990122638b9132ca29c723bdf037f1a891a70c, topic[0] = 0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545 'AND' topic[1] = 0x72657075746174696f6e00000000000000000000000000000000000000000000

/api?module=logs&action=getLogs&fromBlock=379224&toBlock=400000&address=0x33990122638b9132ca29c723bdf037f1a891a70c&topic0=0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545&topic0_1_opr=and&topic1=0x72657075746174696f6e00000000000000000000000000000000000000000000&apikey=YourApiKeyToken

Geth/Parity Proxy APIs

The following are the limited list of supported Proxied APIs for Geth available through Etherscan.

For the list of the parameters and descriptions please see https://github.com/ethereum/wiki/wiki/JSON-RPC. Parameters provided should be named like in the examples below. For compatibility with Parity, please prefix all hex strings with "0x"

eth_blockNumber

Returns the number of most recent block

/api?module=proxy&action=eth_blockNumber&apikey=YourApiKeyToken

eth_getBlockByNumber

Returns information about a block by block number

/api?module=proxy&action=eth_getBlockByNumber&tag=0x10d4f&boolean=true&apikey=YourApiKeyToken

eth_getUncleByBlockNumberAndIndex

Returns information about a uncle by block number

/api?module=proxy&action=eth_getUncleByBlockNumberAndIndex&tag=0x210A9B&index=0x0&apikey=YourApiKeyToken

eth_getBlockTransactionCountByNumber

Returns the number of transactions in a block from a block matching the given block number

/api?module=proxy&action=eth_getBlockTransactionCountByNumber&tag=0x10FB78&apikey=YourApiKeyToken

eth_getTransactionByHash

Returns the information about a transaction requested by transaction hash

/api?module=proxy&action=eth_getTransactionByHash&txhash=0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1&apikey=YourApiKeyToken

eth_getTransactionByBlockNumberAndIndex

Returns information about a transaction by block number and transaction index position

/api?module=proxy&action=eth_getTransactionByBlockNumberAndIndex&tag=0x10d4f&index=0x0&apikey=YourApiKeyToken

eth_getTransactionCount

Returns the number of transactions sent from an address

/api?module=proxy&action=eth_getTransactionCount&address=0x2910543af39aba0cd09dbb2d50200b3e800a63d2&tag=latest&apikey=YourApiKeyToken

eth_sendRawTransaction

Creates new message call transaction or a contract creation for signed transactions

/api?module=proxy&action=eth_sendRawTransaction&hex=0xf904808000831cfde080&apikey=YourApiKeyToken

(Replace the hex value with your raw hex encoded transaction that you want to send.Send as a POST request, if your hex code is particularly long)

eth_getTransactionReceipt

Returns the receipt of a transaction by transaction hash

/api?module=proxy&action=eth_getTransactionReceipt&txhash=0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1&apikey=YourApiKeyToken

eth_call

Executes a new message call immediately without creating a transaction on the block chain

/api?module=proxy&action=eth_call&to=0xAEEF46DB4855E25702F8237E8f403FddcaF931C0&data=0x70a08231000000000000000000000000e16359506c028e51f16be38986ec5746251e9724&tag=latest&apikey=YourApiKeyToken

(The gas parameter to eth_call are capped at 2x the current block gas limit)

eth_getCode

Returns code at a given address

/api?module=proxy&action=eth_getCode&address=0xf75e354c5edc8efed9b59ee9f67a80845ade7d0c&tag=latest&apikey=YourApiKeyToken

eth_getStorageAt

Returns the value from a storage position at a given address

/api?module=proxy&action=eth_getStorageAt&address=0x6e03d9cce9d60f3e9f2597e13cd4c54c55330cfd&position=0x0&tag=latest&apikey=YourApiKeyToken

eth_gasPrice

Returns the current price per gas in wei

/api?module=proxy&action=eth_gasPrice&apikey=YourApiKeyToken

eth_estimateGas

Makes a call or transaction, which won't be added to the blockchain and returns the used gas, which can be used for estimating the used gas

/api?module=proxy&action=eth_estimateGas&to=0xf0160428a8552ac9bb7e050d90eeade4ddd52843&value=0xff22&gasPrice=0x051da038cc&gas=0xffffff&apikey=YourApiKeyToken

(The gas parameter to eth_estimateGas are capped at 2x the current block gas limit)

Token Info APIs

Get ERC20-Token TotalSupply by ContractAddress

/api?module=stats&action=tokensupply&contractaddress=0x57d90b64a1a57749b0f932f1a3395792e12e7055&apikey=YourApiKeyToken

Get Historical ERC20-Token TotalSupply by ContractAddress & BlockNo

/api?module=stats&action=tokensupplyhistory&contractaddress=0x57d90b64a1a57749b0f932f1a3395792e12e7055&blockno=8000000&apikey=YourApiKeyToken

Get ERC20-Token Account Balance for TokenContractAddress

/api?module=account&action=tokenbalance&contractaddress=0x57d90b64a1a57749b0f932f1a3395792e12e7055&address=0xe04f27eb70e025b78871a2ad7eabe85e61212761&tag=latest&apikey=YourApiKeyToken

Get Historical ERC20-Token Account Balance for TokenContractAddress by BlockNo

/api?module=account&action=tokenbalancehistory&contractaddress=0x57d90b64a1a57749b0f932f1a3395792e12e7055&address=0xe04f27eb70e025b78871a2ad7eabe85e61212761&blockno=8000000&apikey=YourApiKeyToken

Get Token Info by ContractAddress

/api?module=token&action=tokeninfo&contractaddress=0x0e3a2a1f2146d86a604adc220b4967a898d7fe07&apikey=YourApiKeyToken

Gas Tracker APIs

Get Estimation of Confirmation Time

/api?module=gastracker&action=gasestimate&gasprice=2000000000&apikey=YourApiKeyToken

(Result returned in seconds, gasprice value in Wei)

Get Gas Oracle

/api?module=gastracker&action=gasoracle&apikey=YourApiKeyToken

General Stats APIs

Get Total Supply of Ether

/api?module=stats&action=ethsupply&apikey=YourApiKeyToken

(Result returned in Wei, to get value in Ether divide resultAbove/1000000000000000000)

Get ETHER Last Price

/api?module=stats&action=ethprice&apikey=YourApiKeyToken

Get Ethereum Nodes Size

[Parameters] startdate and enddate format 'yyyy-MM-dd', clienttype value is 'geth' or 'parity', syncmode value is 'default' or 'archive'

/api?module=stats&action=chainsize&startdate=2019-02-01&enddate=2019-02-28&clienttype=geth&syncmode=default&sort=asc&apikey=YourApiKeyToken

(The chainsize return in bytes.)

Get ETHER Historical Price

[Parameters] startdate and enddate format 'yyyy-MM-dd'

/api?module=stats&action=ethdailyprice&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get ETHER Historical Daily Market Cap

/api?module=stats&action=ethdailymarketcap&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily Transaction Count

/api?module=stats&action=dailytx&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily New Address Count

/api?module=stats&action=dailynewaddress&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily Average Block Size

/api?module=stats&action=dailyavgblocksize&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily Average Block Time for A Block to be Included in the Ethereum Blockchain

/api?module=stats&action=dailyavgblocktime&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily Average Gas Price Used

/api?module=stats&action=dailyavggasprice&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily Average Gas Limit

/api?module=stats&action=dailyavggaslimit&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily Total Gas Used

/api?module=stats&action=dailygasused&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily Block Rewards

/api?module=stats&action=dailyblockrewards&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily Block Count and Block Rewards

/api?module=stats&action=dailyblkcount&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily Uncle Block Count and Uncle Block Rewards

/api?module=stats&action=dailyuncleblkcount&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily Average Network Hash Rate

/api?module=stats&action=dailyavghashrate&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily Average Network Difficulty

/api?module=stats&action=dailyavgnetdifficulty&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily Total Transaction Fee

/api?module=stats&action=dailytxnfee&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily Network Utilization

/api?module=stats&action=dailynetutilization&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get Daily ENS Registration Count

/api?module=stats&action=dailyensregister&startdate=2019-02-01&enddate=2019-02-28&sort=asc&apikey=YourApiKeyToken

Get DeFi Leaderboard

[Parameters] date format 'yyyy-MM-dd', sortby value is 'marketcap' or 'totallock'

/api?module=stats&action=defileaderboard&date=2020-09-01&sortby=marketcap&sort=desc&apikey=YourApiKeyToken

Etherscan API 约定 — Etherscan API 中文文档 — 深入浅出区块链

Etherscan API 约定 — Etherscan API 中文文档 — 深入浅出区块链

深入浅出区块链

Etherscan API 中文文档

Latest

Etherscan APIs 手册

Etherscan API 约定

包含模块

参数

测试网络接口Host

账号(Account)

获取单个账号余额

获取多个账号余额

获取地址(普通)交易列表

获取地址”内部”交易列表

获取地址ERC20转账交易列表

获取地址所挖区块列表

智能合约(Contracts)

获取已经验证代码合约的ABI

获取已经验证代码合约的源码

[BETA] 验证源代码

交易(Transaction)

[BETA] 检查合约执行状态

[BETA] 检查交易收据状态

区块(Blocks)

通过区块号获取块及叔块奖励

事件日志 (Event Logs)

通过指定区块获取日志

通过指定区块获取日志

节点代理(Geth/Parity Proxy) APIs

获取最近区块号

通过区块号查询区块信息

通过区块号查询叔块信息

通过区块号查询交易数量

通过哈希查询交易信息

通过区块号查询交易信息

通过地址的交易数量

发送原始交易

通过哈希查询交易收据

执行消息调用

获取地址代码

获取地址上某个位置的值 (体验功能)

获取当前gas Price

测量gas Limit

代币信息 Token

通过合约地址获取ERC20 Token总供应量

获取ERC20代币余额

常规状态数据(General Stats)

获取以太总供应量

获取以太最新价格

获取节点大小(Size)

第三方工具(Utils)

Python API 封装 (by corpetty)

node API 封装 ( by Sebastian Schürmann)

Go API

Php 接口

帮助手册-用Markdown写Sphinx

Markdown转reST

数学公式

参考

相关文档

Solidity 中文文档

ethers.js 中文文档

Web3.js 中文文档

Etherscan API 中文文档

Docs »

Etherscan API 约定

Edit on GitHub

Etherscan API 约定¶

当前翻译Etherscan官方 API时间为2019年4月,因官方API没有版本号,这里用时间做一个标注。

包含模块¶

Etherscan API 主要包含模块有:

账号地址相关接口

智能合约相关接口

交易相关接口

区块相关接口

事件日志相关接口

Tokens代币相关接口

状态相关接口

一些相关工具相关接口

这些模块对应着左侧的一级菜单,在接口中使用module参数指定

参数¶

参数说明:

module: 指明接口所属模块,即上面包含的模块

action: API动作,如:txlist - 表示列出交易记录;

address: 所查询交易的账号地址;

contractaddress: 合约地址

apikey: 用户API-key 根据key来统计请求限额;

startblock: 起始查询块 id,可选,默认值为 0;

endblock: 结束查询块 id,可选,默认值为最后一个区块;

tag: 状态:pending 或 latest

blocktype: 块类型:blocks(主链块) 或 uncles (叔块)

page: 页码,可选;

offset: 每页查询记录数,可选,默认是查询 10000 条记录;

sort: 排序规则,支持正序asc和倒序desc。

module、action、apikey是每个 API 都有的参数,其他的参数则因不同 API 而不同,这里做一个统一的介绍,后面介绍接口时不再单独说明。

测试网络接口Host¶

主网的Host是 api.etherscan.io,其实Etherscan API 所有接口在测试网络下也使用,只是所使用的域名不同,目前支持的三个网络的Host为:

api-ropsten.etherscan.io

api-kovan.etherscan.io

api-rinkeby.etherscan.io

Next

Previous

© Copyright 2019, 深入浅出区块链

最后更新于 2019/5月/10.

Built with Sphinx using a theme provided by Read the Docs.

Etherscan Information Center | API Keys

rscan Information Center | API KeysInformation Center

Newsletter

Glossary

Go to EtherscanSearchHomeTutorialsAPI KeysAPI KeysOn Etherscan, we provide an array of APIs for data pertaining to transactions, contracts, accounts, stats and other components of the Ethereum blockchain. For the full list of our currently available APIs, kindly refer here.

You must be a registered Etherscan user with your own API keys to use the APIs. Take note that the APIs are free-to-use but with a limitation of 5 calls per second put in place to ensure a smooth experience to the collective users.

To create your API key:

Log in to your Etherscan account here. If you have yet registered for an account, you can refer to our sign up guide or register here.

Upon login, you should be directed to your Client Portal & Services. There, look to the left side of the page for a tab called API-KEYs.

On My API Keys page, click on the + Add New button where after which you will be prompted to insert an AppName for the API key that you are currently creating.

You have successfully created your first API key!

To edit your API key:

To change the AppName of your API key, go to My API Keys page and click on the Edit button located next to the API key that you want to edit. You can also view the usage statistics of an API key by clicking on the Stat button located next to the Edit button.

Each Etherscan account is limited to only 3 API keys and they cannot be deleted by the user.

The API keys created on Etherscan.io can also be used for the Kovan, Rinkeby, Ropsten, and Goerli Testnets.

Source attribution via a link back or mention that your app is "Powered by Etherscan.io APIs" is required except for personal/private usage.

Refer here for API key rate limit & expected error returns.

Please contact us if you would like to upgrade your API Plan.

Raja Amir

Last updated: 8th August 2023Related ArticlesPro Tips for Advanced FilterToken Holdings DropdownMethod IDEvent LogsUnderstanding ERC-4337 Account AbstractionCode ReaderStill Have Questions?Contact UsOur support team's ready for your questions, anytime.Priority SupportA Paid Service for priority handling of your needs and queries.Developer DocsIn-depth explanations on technical issues faced by developers.© 2023 Etherscan Information Cen

智能合约(Contracts) — Etherscan API 中文文档 — 深入浅出区块链

智能合约(Contracts) — Etherscan API 中文文档 — 深入浅出区块链

深入浅出区块链

Etherscan API 中文文档

Latest

Etherscan APIs 手册

Etherscan API 约定

包含模块

参数

测试网络接口Host

账号(Account)

获取单个账号余额

获取多个账号余额

获取地址(普通)交易列表

获取地址”内部”交易列表

获取地址ERC20转账交易列表

获取地址所挖区块列表

智能合约(Contracts)

获取已经验证代码合约的ABI

获取已经验证代码合约的源码

[BETA] 验证源代码

交易(Transaction)

[BETA] 检查合约执行状态

[BETA] 检查交易收据状态

区块(Blocks)

通过区块号获取块及叔块奖励

事件日志 (Event Logs)

通过指定区块获取日志

通过指定区块获取日志

节点代理(Geth/Parity Proxy) APIs

获取最近区块号

通过区块号查询区块信息

通过区块号查询叔块信息

通过区块号查询交易数量

通过哈希查询交易信息

通过区块号查询交易信息

通过地址的交易数量

发送原始交易

通过哈希查询交易收据

执行消息调用

获取地址代码

获取地址上某个位置的值 (体验功能)

获取当前gas Price

测量gas Limit

代币信息 Token

通过合约地址获取ERC20 Token总供应量

获取ERC20代币余额

常规状态数据(General Stats)

获取以太总供应量

获取以太最新价格

获取节点大小(Size)

第三方工具(Utils)

Python API 封装 (by corpetty)

node API 封装 ( by Sebastian Schürmann)

Go API

Php 接口

帮助手册-用Markdown写Sphinx

Markdown转reST

数学公式

参考

相关文档

Solidity 中文文档

ethers.js 中文文档

Web3.js 中文文档

Etherscan API 中文文档

Docs »

智能合约(Contracts)

Edit on GitHub

智能合约(Contracts)¶

智能合约相关的 API,接口的参数说明请参考Etherscan API 约定, 文档中不单独说明。

Newly verified Contracts are synced to the API servers within 5 minutes or less

获取已经验证代码合约的ABI¶

Verified Contract Source Codes

https://api.etherscan.io/api?module=contract&action=getabi&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=YourApiKeyToken

A simple sample for retrieving the contractABI using Web3.js and Jquery to interact with a contract

var Web3 = require('web3');

var web3 = new Web3(new Web3.providers.HttpProvider());

var version = web3.version.api;

$.getJSON('http://api.etherscan.io/api?module=contract&action=getabi&address=0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359', function (data) {

var contractABI = "";

contractABI = JSON.parse(data.result);

if (contractABI != ''){

var MyContract = web3.eth.contract(contractABI);

var myContractInstance = MyContract.at("0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359");

var result = myContractInstance.memberId("0xfe8ad7dd2f564a877cc23feea6c0a9cc2e783715");

console.log("result1 : " + result);

var result = myContractInstance.members(1);

console.log("result2 : " + result);

} else {

console.log("Error" );

}

});

获取已经验证代码合约的源码¶

https://api.etherscan.io/api?module=contract&action=getsourcecode&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=YourApiKeyToken

[BETA] 验证源代码¶

1. Requires a valid Etherscan APIkey, will reject if otherwise

2. Current daily limit of 100 submissions per day per user (subject to change)

3. Only supports HTTP post due to max transfer size limitations for http get

4. Supports up to 10 different library pairs

5. Contracts that use "imports" will need to have the code concatenated into one file as we do not support "imports" in separate files. You can try using the Blockcat solidity-flattener or SolidityFlattery

6. List of supported solc versions, only solc version v0.4.11 and above is supported. Ex. v0.4.25+commit.59dbf8f1

7. Upon successful submission you will receive a GUID (50 characters) as a receipt.

8. You may use this GUID to track the status of your submission

9. Verified Source Codes will be displayed at contractsVerified

See Demo Source Verification Submission Code at Source Code Verification Sample

Source Code Submission Gist (returns a guid as part of the result upon success):

//Submit Source Code for Verification

$.ajax({

type: "POST", //Only POST supported

url: "//api.etherscan.io/api", //Set to the correct API url for Other Networks

data: {

apikey: $('#apikey').val(), //A valid API-Key is required

module: 'contract', //Do not change

action: 'verifysourcecode', //Do not change

contractaddress: $('#contractaddress').val(), //Contract Address starts with 0x...

sourceCode: $('#sourceCode').val(), //Contract Source Code (Flattened if necessary)

contractname: $('#contractname').val(), //ContractName

compilerversion: $('#compilerversion').val(), // see http://etherscan.io/solcversions for list of support versions

optimizationUsed: $('#optimizationUsed').val(), //0 = Optimization used, 1 = No Optimization

runs: 200, //set to 200 as default unless otherwise

constructorArguements: $('#constructorArguements').val(), //if applicable

libraryname1: $('#libraryname1').val(), //if applicable, a matching pair with libraryaddress1 required

libraryaddress1: $('#libraryaddress1').val(), //if applicable, a matching pair with libraryname1 required

libraryname2: $('#libraryname2').val(), //if applicable, matching pair required

libraryaddress2: $('#libraryaddress2').val(), //if applicable, matching pair required

libraryname3: $('#libraryname3').val(), //if applicable, matching pair required

libraryaddress3: $('#libraryaddress3').val(), //if applicable, matching pair required

libraryname4: $('#libraryname4').val(), //if applicable, matching pair required

libraryaddress4: $('#libraryaddress4').val(), //if applicable, matching pair required

libraryname5: $('#libraryname5').val(), //if applicable, matching pair required

libraryaddress5: $('#libraryaddress5').val(), //if applicable, matching pair required

libraryname6: $('#libraryname6').val(), //if applicable, matching pair required

libraryaddress6: $('#libraryaddress6').val(), //if applicable, matching pair required

libraryname7: $('#libraryname7').val(), //if applicable, matching pair required

libraryaddress7: $('#libraryaddress7').val(), //if applicable, matching pair required

libraryname8: $('#libraryname8').val(), //if applicable, matching pair required

libraryaddress8: $('#libraryaddress8').val(), //if applicable, matching pair required

libraryname9: $('#libraryname9').val(), //if applicable, matching pair required

libraryaddress9: $('#libraryaddress9').val(), //if applicable, matching pair required

libraryname10: $('#libraryname10').val(), //if applicable, matching pair required

libraryaddress10: $('#libraryaddress10').val() //if applicable, matching pair required

},

success: function (result) {

console.log(result);

if (result.status == "1") {

//1 = submission success, use the guid returned (result.result) to check the status of your submission.

// Average time of processing is 30-60 seconds

document.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result;

// result.result is the GUID receipt for the submission, you can use this guid for checking the verification status

} else {

//0 = error

document.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result;

}

console.log("status : " + result.status);

console.log("result : " + result.result);

},

error: function (result) {

console.log("error!");

document.getElementById("postresult").innerHTML = "Unexpected Error"

}

});

Check Source code verification submission status:

//Check Source Code Verification Status

$.ajax({

type: "GET",

url: "//api.etherscan.io/api",

data: {

guid: 'ezq878u486pzijkvvmerl6a9mzwhv6sefgvqi5tkwceejc7tvn', //Replace with your Source Code GUID receipt above

module: "contract",

action: "checkverifystatus"

},

success: function (result) {

console.log("status : " + result.status); //0=Error, 1=Pass

console.log("message : " + result.message); //OK, NOTOK

console.log("result : " + result.result); //result explanation

$('#guidstatus').html(">> " + result.result);

},

error: function (result) {

alert('error');

}

});

Next

Previous

© Copyright 2019, 深入浅出区块链

最后更新于 2019/5月/10.

Built with Sphinx using a theme provided by Read the Docs.

Etherscan API中文手册 - 汇智网

Etherscan API中文手册 - 汇智网

Toggle navigation

教程目录

互动课程

官方博客

登录

注册

Etherscan API中文手册

账号API

account - 以太坊账号API模块

account/balance - 获取指定地址的余额

account/balancemulti - 获取多个地址的余额

account/txlist - 获取指定地址的普通交易

account/txlistinternal - 获取指定地址的内部交易

account/txlistinternal - 获取指定交易触发的内部交易

account/tokentx - 获取指定地址的ERC20代币转账交易

account/getminedblock - 获取指定地址挖出的区块

合约API

contract - 智能合约API模块

contract/getabi - 获取指定合约的ABI

contract/getcode - 获取指定合约的源代码

contract/verifysourcecode - 验证指定合约的源代码

contract/checkverifystatus - 获取源代码验证结果

交易API

transaction - 交易API模块

transaction/getstatus - 获取指定交易的执行状态

transaction/gettxreceiptstatus - 获取指定交易的收据状态

区块API

block - 区块API模块

block/getblockreward - 获取指定区块奖励额

事件日志API

logs - 日志API模块

logs/getLogs - 获取以太坊日志

节点代理API

proxy - 节点代理API模块

proxy/eth_blockNumber - 获取链头区块编号

proxy/eth_getBlockByNumber - 获取指定编号的区块详情

proxy/eth_getUncleByBlockNumberAndIndex - 获取指定的叔伯区块详情

proxy/eth_getBlockTransactionCountByNumber - 获取指定编号区块的交易数量

proxy/eth_getTransactionByHash - 获取指定哈希交易的详情

proxy/eth_getTransactionByBlockNumberAndIndex - 获取指定区块及序号交易的详情

proxy/eth_getTransactionCount - 获取指定地址发生的交易数量

proxy/eth_sendRawTransaction - 发送裸交易

proxy/eth_getTransactionReceipt - 获取指定交易的收据

proxy/eth_call - 执行消息调用

proxy/eth_getCode - 获取指定地址的代码

proxy/eth_getStorageAt - 获取指定位置的内容

proxy/eth_gasPrice - 获取当前的gas价格

proxy/eth_estimateGas - 估算交易gas用量

通证/代币API

token - 代币API概述

stats/tokensupply - 获取指定ERC20代币的总供应量

account/tokenbalance - 获取指定账号的ERC20代币余额

统计API

stats - 统计API模块

stats/ethsupply - 获取以太币当前总量

stats/ethprice - 获取以太币最新价格

stats/chainsize - 获取节点数据大小

开发包

Etherscan开发包

全部教程

Etherscan API中文手册

Etherscan API中文手册

在线工具推荐:

Three.js AI纹理开发包 -

YOLO合成数据生成器 -

GLTF/GLB在线编辑 -

3D模型格式在线转换 -

可编程3D场景编辑器

Etherscan API

Etherscan以太坊API仅作为社区服务提供,Etherscan并不提供任何承诺与保证,

请根据你的需求使用,Etherescan API同时支持GET/POST请求,目前限流为5次/秒。

要使用Etherescan API,你需要点击这里创建一个

免费的Api密钥令牌,在调用Etherscan API时,需要使用这个API令牌。如果是在商业应用

或站点中使用Etherscan API,你必须添加到Etherscan的链接,或者说明你的应用是

Powered by Etherscan.io API。

Etherscan API根据用途分为几个模块:

account:账号地址相关API

contract:智能合约相关API

transaction:交易相关API

block:区块相关API

logs:事件日志相关API

proxy:节点代理API

token:通证/代币相关API

stats:统计信息相关API

Etherscan在支持公链浏览方面是无可挑剔的,但对于开发者来讲,有一个缺憾

就是Etherscan不支持私有链或ganache仿真器区块浏览,这种情况下建议使用

ETHSCAN ,一个单文件的、可以离线使用的

以太坊浏览器。

account模块

etherscan的account模块提供与以太坊账号/地址相关的API,主要提供以下方法:

account/balance:获取指定账号/地址的以太币余额

account/balancemulti:获取多个账号/地址的以太币余额

account/txlist:获取指定账号/地址发生的以太坊普通交易清单

account/txlistinternal:获取指定账号/地址发生的内部交易,或者获取指定交易触发的内部交易

account/tokentx:获取指定账号/地址的ERC20代币交易清单

account/getminedblock:获取指定账号/地址挖出的区块

contract模块

Etherscan的contract模块提供与以太坊智能合约相关的API,主要包括:

contract/getabi:获取指定合约的abi数据

contract/getcode:获取指定合约的源代码

contract/verifysource:验证指定合约的源代码

contract/checkverifystatus:获取合约验证结果

transaction模块

Etherscan的transaction模块提供与交易查询相关的API,主要包括:

transaction/getstatus:获取指定交易的执行状态

transaction/gettxreceiptstatus:获取指定交易收据的状态

block模块

Etherscan的block模块主要提供与区块查询相关的API,主要包括:

block/getblockreward:获取指定区块的出块奖励金额

logs模块

Etherscan的logs模块只要提供与以太坊日志查询有关的API,主要包括:

logs/getLogs;获取以太坊日志

proxy模块

Etherscan的proxy模块主要提供对Geth/Parity以太坊节点的RPC API的代理,

主要包括以下API:

proxy/eth_blockNumber: 获取链头区块编号

proxy/eth_getBlockByNumber: 获取指定编号的区块详情

proxy/eth_getUncleByBlockNumberAndIndex: 获取指定的叔伯区块详情

proxy/eth_getBlockTransactionCountByNumber: 获取指定编号区块的交易数量

proxy/eth_getTransactionByHash: 获取指定哈希交易的详情

proxy/eth_getTransactionByBlockNumberAndIndex: 获取指定区块及序号交易的详情

proxy/eth_getTransactionCount: 获取指定地址发生的交易数量

proxy/eth_sendRawTransaction: 发送裸交易

proxy/eth_getTransactionReceipt: 获取指定交易的收据

proxy/eth_call: 执行消息调用

proxy/eth_getCode: 获取指定地址的代码

proxy/eth_getStorageAt: 获取指定位置的内容

proxy/eth_gasPrice: 获取当前的gas价格

proxy/eth_estimateGas: 估算交易gas用量

token模块

Etherscan中与ERC20代币相关的API主要包括如下:

stats/tokensupply:获取指定代币的供应总量

account/tokenbalance:获取指定地址的特定代币的余额

stats模块

Etherscan的stats模块主要提供以太坊统计数据相关的API,主要包括:

stats/ethsupply - 获取以太币当前总量

stats/ethprice - 获取以太币最新价格

stats/chainsize - 获取节点数据大小

在线互动课程

web3j以太坊开发详解

python以太坊开发详解

php以太坊开发详解

C#以太坊开发详解

以太坊DApp开发入门

以太坊电商DApp实战

java比特币开发详解

php比特币开发详解

C#比特币开发详解

EOS区块链DApp开发入门

深入浅出玩转EOS钱包开发

tendermint区块链开发详解

Fabric区块链Nodejs开发详解

Fabric区块链Java开发详解

订阅免费课程

获取免费课程推送

订阅免费课程

账号(Account) — Etherscan API 中文文档 — 深入浅出区块链

账号(Account) — Etherscan API 中文文档 — 深入浅出区块链

深入浅出区块链

Etherscan API 中文文档

Latest

Etherscan APIs 手册

Etherscan API 约定

包含模块

参数

测试网络接口Host

账号(Account)

获取单个账号余额

获取多个账号余额

获取地址(普通)交易列表

获取地址”内部”交易列表

获取地址ERC20转账交易列表

获取地址所挖区块列表

智能合约(Contracts)

获取已经验证代码合约的ABI

获取已经验证代码合约的源码

[BETA] 验证源代码

交易(Transaction)

[BETA] 检查合约执行状态

[BETA] 检查交易收据状态

区块(Blocks)

通过区块号获取块及叔块奖励

事件日志 (Event Logs)

通过指定区块获取日志

通过指定区块获取日志

节点代理(Geth/Parity Proxy) APIs

获取最近区块号

通过区块号查询区块信息

通过区块号查询叔块信息

通过区块号查询交易数量

通过哈希查询交易信息

通过区块号查询交易信息

通过地址的交易数量

发送原始交易

通过哈希查询交易收据

执行消息调用

获取地址代码

获取地址上某个位置的值 (体验功能)

获取当前gas Price

测量gas Limit

代币信息 Token

通过合约地址获取ERC20 Token总供应量

获取ERC20代币余额

常规状态数据(General Stats)

获取以太总供应量

获取以太最新价格

获取节点大小(Size)

第三方工具(Utils)

Python API 封装 (by corpetty)

node API 封装 ( by Sebastian Schürmann)

Go API

Php 接口

帮助手册-用Markdown写Sphinx

Markdown转reST

数学公式

参考

相关文档

Solidity 中文文档

ethers.js 中文文档

Web3.js 中文文档

Etherscan API 中文文档

Docs »

账号(Account)

Edit on GitHub

账号(Account)¶

账号及地址相关的 API,接口的参数说明请参考Etherscan API 约定, 文档中不单独说明。

获取单个账号余额¶

注解

译者注:英文 balance 有人翻译为`金额`,译者习惯称为`余额`。

账号和地址大部分也是指一个意思。

接口:

/api?module=account&action=balance&address=0x&tag=latest&apikey=YourApiKeyToken

返回:

{

status: "1",

message: "OK",

result: "40807178566070000000000"

}

说明:

余额的单位都是最小单位wei, 更多单位换算可阅读:以太单位换算

请求样例URL,点击可在浏览器查看效果。

获取多个账号余额¶

接口:

/api?module=account&action=balancemulti&address=0xabc,0x63..,0x198..&tag=latest&apikey=YourApiKeyToken

使用,来分割地址,一次请求最多20个账号。

返回:

{

status: "1",

message: "OK",

result: [

{

account: "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a",

balance: "40807178566070000000000"

},

{

account: "0x63a9975ba31b0b9626b34300f7f627147df1f526",

balance: "332567136222827062478"

}

]

}

请求样例URL

获取地址(普通)交易列表¶

接口:

/api?module=account&action=txlist&address=&apikey=YourApiKeyToken

可选参数:startblock 、endblock、sort

返回:

{

"status": "1",

"message": "OK",

"result": [{

"blockNumber": "47884",

"timeStamp": "1438947953",

"hash": "0xad1c27dd8d0329dbc400021d7477b34ac41e84365bd54b45a4019a15deb10c0d",

"nonce": "0",

"blockHash": "0xf2988b9870e092f2898662ccdbc06e0e320a08139e9c6be98d0ce372f8611f22",

"transactionIndex": "0",

"from": "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a",

"to": "0x2910543af39aba0cd09dbb2d50200b3e800a63d2",

"value": "5000000000000000000",

"gas": "23000",

"gasPrice": "400000000000",

"isError": "0",

"txreceipt_status": "",

"input": "0x454e34354139455138",

"contractAddress": "",

"cumulativeGasUsed": "21612",

"gasUsed": "21612",

"confirmations": "7525550"

}]

}

说明:

isError: 0= 没错, 1=出错

最多返回最近的10000个交易

返回字段中出现的关键字可参考以太坊设计与实现-术语。

请求样例URL

也可以使用分页,参数说明请参考Etherscan API 约定,分页请求样例URL

获取地址”内部”交易列表¶

内部交易只指引一个正常(外部)交易(连带)触发的交易,比如过一个合约调用触发的内部交易。

接口:

/api?module=account&action=txlistinternal&address=

可选参数:startblock 、endblock、sort

返回结果和普通交易列表JSON结构一样。

请求样例URL

获取地址ERC20转账交易列表¶

转账交易是通过Transfer事件来判定的。

接口:

/api?module=account&action=tokentx&address=&contractaddress

说明: 可选参数:startblock 、endblock、contractaddress 、sort

可以通过参数contractaddress来指定某一个合约的交易。

返回和上面普通交易列表JSON结构一样。

请求样例:

使用普通地址请求ERC20转账列表

仅使用合约地址请求ERC20转账列表

同时使用普通地址和合约地址请求ERC20转账列表

获取地址所挖区块列表¶

接口:

/api?module=account&action=getminedblocks&address=&blocktype=blocks

说明:blocktype 值为 blocks(仅显示主链块) 或 uncles (仅显示叔块) , blocks为默认值

返回:

{

status: "1",

message: "OK",

result: [

{

blockNumber: "3462296",

timeStamp: "1491118514",

blockReward: "5194770940000000000"

},

{

blockNumber: "2691400",

timeStamp: "1480072029",

blockReward: "5086562212310617100"

}

]

}

说明:

blockReward :区块奖励, 同样使用最小单位wei, 更多单位换算可阅读:以太单位换算

请求样例URL及分页请求

Next

Previous

© Copyright 2019, 深入浅出区块链

最后更新于 2019/5月/10.

Built with Sphinx using a theme provided by Read the Docs.

Postman

Postman

Etherscan Information Center | Etherscan Developer API Key

rscan Information Center | Etherscan Developer API KeyInformation Center

Newsletter

Glossary

Go to EtherscanSearchHomeDeveloperEtherscan Developer API Key 🔑Etherscan Developer API Key 🔑

The Ethereum Developer APIs are provided as a community service and without warranty, so please just use what you need and no more.

The Etherscan Ethereum Developer APIs supports both GET/POST requests and a rate limit of 5 requests/sec.

To use the API service please create a FREE Api-Key Token from within the ClientPortal->MyApiKey area which you can then use with all your api requests.

You may receive a HTTP 403 error if exceed this limit.

Kindly credit/link back or mention that your app is "Powered by Etherscan.io APIs" would be very much appreciated.

Kaven Choi

Last updated: 8th August 2023Related ArticlesUsing the API ServiceVerifying ContractsAPI Key Rate Limit & ErrorsHow to determine the correct constructor argument during contract source code verification on EtherscanContract Verification - Constructor ArgumentsContract Troubleshooting - Unable to Verify Contract SourceStill Have Questions?Contact UsOur support team's ready for your questions, anytime.Priority SupportA Paid Service for priority handling of your needs and queries.Developer DocsIn-depth explanations on technical issues faced by developers.© 2023 Etherscan Information Cen