├── .gitignore ├── Makefile ├── Readme.md ├── make.bat └── source ├── Accounts.md ├── Blocks.md ├── Contracts.md ├── EventLogs.md ├── GethParityProxy.md ├── Introduction.md ├── MiscToolsUtilities.md ├── Stats.md ├── Tokens.md ├── Transactions.md ├── _static └── z_stat.js ├── _templates ├── breadcrumbs.html ├── footer.html └── layout.html ├── conf.py ├── index.rst └── sphinx.md /.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SOURCEDIR = source 8 | BUILDDIR = build 9 | 10 | # Put it first so that "make" without argument is like "make help". 11 | help: 12 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 13 | 14 | .PHONY: help Makefile 15 | 16 | # Catch-all target: route all unknown targets to Sphinx using the new 17 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 18 | %: Makefile 19 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # [Etherscan APIs 中文文档](https://learnblockchain.cn/docs/etherscan/) 2 | 3 | [官方文档](https://etherscan.io/apis)只提供了几个接口,基本上没有说明。 4 | 希望这份中文文档可以帮到大家,文档Web地址托管在[深入浅出区块链-文档中心](https://learnblockchain.cn/docs/etherscan/)。 5 | 6 | 7 | ## 贡献 8 | 9 | 本文档由[深入浅出区块链](https://learnblockchain.cn)社区成员翻译整理。 10 | 欢迎大家加入,申请成为贡献者,微信添加Tiny熊(xlbxiong),或者发邮件:xlb@upchain.pro 11 | 12 | 13 | ### Sphinx 安装 14 | 15 | ``` 16 | sudo pip install -U Sphinx 17 | pip install sphinx_rtd_theme 18 | pip install --upgrade recommonmark 19 | ``` 20 | 21 | ### 支持 RST 及Markdown格式 22 | 23 | RST文档格式的一个[中文说明](http://www.cnblogs.com/seayxu/p/5603876.html) 24 | 25 | ## 感谢 26 | 27 | 感谢[登链学院](http://edu.upchain.pro/)提供服务器赞助. 28 | 29 | -------------------------------------------------------------------------------- /make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /source/Accounts.md: -------------------------------------------------------------------------------- 1 | # 账号(Account) 2 | 3 | 账号及地址相关的 API,接口的参数说明请参考[Etherscan API 约定](Introduction.md), 文档中不单独说明。 4 | 5 | ## 获取单个账号余额 6 | 7 | ``` note:: 8 | 译者注: 9 | 英文 `balance` 有人翻译为`金额`,译者习惯称为`余额`。 10 | 账号和地址大部分也是指一个意思。 11 | ``` 12 | 13 | 接口: 14 | 15 | ``` 16 | /api?module=account&action=balance&address=0x&tag=latest&apikey=YourApiKeyToken 17 | ``` 18 | 19 | 返回: 20 | ```js 21 | { 22 | status: "1", 23 | message: "OK", 24 | result: "40807178566070000000000" 25 | } 26 | ``` 27 | 28 | 说明: 29 | 30 | 余额的单位都是最小单位`wei`, 更多单位换算可阅读:[以太单位换算](https://learnblockchain.cn/2018/02/02/solidity-unit/) 31 | 32 | 请求样例[URL](https://api.etherscan.io/api?module=account&action=balance&address=0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae&tag=latest&apikey=YourApiKeyToken),点击可在浏览器查看效果。 33 | 34 | 35 | ## 获取多个账号余额 36 | 37 | 接口: 38 | ``` 39 | /api?module=account&action=balancemulti&address=0xabc,0x63..,0x198..&tag=latest&apikey=YourApiKeyToken 40 | ``` 41 | 使用`,`来分割地址,一次请求最多20个账号。 42 | 43 | 返回: 44 | 45 | ```js 46 | { 47 | status: "1", 48 | message: "OK", 49 | result: [ 50 | { 51 | account: "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a", 52 | balance: "40807178566070000000000" 53 | }, 54 | { 55 | account: "0x63a9975ba31b0b9626b34300f7f627147df1f526", 56 | balance: "332567136222827062478" 57 | } 58 | ] 59 | } 60 | ``` 61 | 62 | 63 | 请求样例[URL](https://api.etherscan.io/api?module=account&action=balancemulti&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a,0x63a9975ba31b0b9626b34300f7f627147df1f526,0x198ef1ec325a96cc354c7266a038be8b5c558f67&tag=latest&apikey=YourApiKeyToken) 64 | 65 | 66 | ## 获取地址(普通)交易列表 67 | 68 | 接口: 69 | 70 | ``` 71 | /api?module=account&action=txlist&address=&apikey=YourApiKeyToken 72 | ``` 73 | 74 | 可选参数:`startblock` 、`endblock`、`sort` 75 | 76 | 返回: 77 | 78 | ```js 79 | { 80 | "status": "1", 81 | "message": "OK", 82 | "result": [{ 83 | "blockNumber": "47884", 84 | "timeStamp": "1438947953", 85 | "hash": "0xad1c27dd8d0329dbc400021d7477b34ac41e84365bd54b45a4019a15deb10c0d", 86 | "nonce": "0", 87 | "blockHash": "0xf2988b9870e092f2898662ccdbc06e0e320a08139e9c6be98d0ce372f8611f22", 88 | "transactionIndex": "0", 89 | "from": "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a", 90 | "to": "0x2910543af39aba0cd09dbb2d50200b3e800a63d2", 91 | "value": "5000000000000000000", 92 | "gas": "23000", 93 | "gasPrice": "400000000000", 94 | "isError": "0", 95 | "txreceipt_status": "", 96 | "input": "0x454e34354139455138", 97 | "contractAddress": "", 98 | "cumulativeGasUsed": "21612", 99 | "gasUsed": "21612", 100 | "confirmations": "7525550" 101 | }] 102 | } 103 | ``` 104 | 105 | 说明: 106 | 107 | **isError**: 0= 没错, 1=出错 108 | 最多返回最近的10000个交易 109 | 110 | 返回字段中出现的关键字可参考[以太坊设计与实现-术语](https://learnblockchain.cn/books/geth/term.html)。 111 | 112 | 113 | 请求样例[URL](http://api.etherscan.io/api?module=account&action=txlist&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&startblock=0&endblock=99999999&sort=asc&apikey=YourApiKeyToken) 114 | 115 | 也可以使用分页,参数说明请参考[Etherscan API 约定](Introduction.md),分页请求样例[URL](https://api.etherscan.io/api?module=account&action=txlist&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&startblock=0&endblock=99999999&page=1&offset=10&sort=asc&apikey=YourApiKeyToken) 116 | 117 | 118 | 119 | ## 获取地址”内部”交易列表 120 | 121 | 内部交易只指引一个正常(外部)交易(连带)触发的交易,比如过一个合约调用触发的内部交易。 122 | 123 | 接口: 124 | ``` 125 | /api?module=account&action=txlistinternal&address= 126 | ``` 127 | 128 | 可选参数:`startblock` 、`endblock`、`sort` 129 | 130 | 返回结果和普通交易列表JSON结构一样。 131 | 132 | 请求样例[URL](http://api.etherscan.io/api?module=account&action=txlistinternal&address=0x2c1ba59d6f58433fb1eaee7d20b26ed83bda51a3&startblock=0&endblock=2702578&sort=asc&apikey=YourApiKeyToken) 133 | 134 | 135 | ## 获取地址ERC20转账交易列表 136 | 137 | 转账交易是通过`Transfer`事件来判定的。 138 | 139 | 140 | 接口: 141 | ``` 142 | /api?module=account&action=tokentx&address=&contractaddress 143 | ``` 144 | 145 | 说明: 可选参数:`startblock` 、`endblock`、`contractaddress` 、`sort` 146 | 可以通过参数`contractaddress`来指定某一个合约的交易。 147 | 148 | 149 | 返回和上面普通交易列表JSON结构一样。 150 | 151 | 请求样例: 152 | 153 | 1. [使用普通地址请求ERC20转账列表](http://api.etherscan.io/api?module=account&action=tokentx&address=0x4e83362442b8d1bec281594cea3050c8eb01311c&startblock=0&endblock=999999999&sort=asc&apikey=YourApiKeyToken) 154 | 2. [仅使用合约地址请求ERC20转账列表](https://api.etherscan.io/api?module=account&action=tokentx&contractaddress=0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2&page=1&offset=100&sort=asc&apikey=YourApiKeyToken) 155 | 3. [同时使用普通地址和合约地址请求ERC20转账列表](https://api.etherscan.io/api?module=account&action=tokentx&contractaddress=0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2&address=0x4e83362442b8d1bec281594cea3050c8eb01311c&page=1&offset=100&sort=asc&apikey=YourApiKeyToken) 156 | 157 | ## 获取地址所挖区块列表 158 | 159 | 接口: 160 | ``` 161 | /api?module=account&action=getminedblocks&address=&blocktype=blocks 162 | ``` 163 | 164 | 说明:blocktype 值为 blocks(仅显示主链块) 或 uncles (仅显示叔块) , blocks为默认值 165 | 166 | 167 | 返回: 168 | 169 | ```js 170 | { 171 | status: "1", 172 | message: "OK", 173 | result: [ 174 | { 175 | blockNumber: "3462296", 176 | timeStamp: "1491118514", 177 | blockReward: "5194770940000000000" 178 | }, 179 | { 180 | blockNumber: "2691400", 181 | timeStamp: "1480072029", 182 | blockReward: "5086562212310617100" 183 | } 184 | ] 185 | } 186 | ``` 187 | 188 | 说明: 189 | **blockReward** :区块奖励, 同样使用最小单位`wei`, 更多单位换算可阅读:[以太单位换算](https://learnblockchain.cn/2018/02/02/solidity-unit/) 190 | 191 | 192 | 193 | 请求样例[URL](https://api.etherscan.io/api?module=account&action=getminedblocks&address=0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b&blocktype=blocks&apikey=YourApiKeyToken)及[分页请求](https://api.etherscan.io/api?module=account&action=getminedblocks&address=0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b&blocktype=blocks&page=1&offset=10&apikey=YourApiKeyToken) 194 | -------------------------------------------------------------------------------- /source/Blocks.md: -------------------------------------------------------------------------------- 1 | # 区块(Blocks) 2 | 3 | 区块相关的 API,接口的参数说明请参考[Etherscan API 约定](Introduction.md), 文档中不单独说明。 4 | 5 | 6 | ## 通过区块号获取块及叔块奖励 7 | 8 | ``` 9 | https://api.etherscan.io/api?module=block&action=getblockreward&blockno=2165403&apikey=YourApiKeyToken 10 | ``` 11 | 12 | 13 | -------------------------------------------------------------------------------- /source/Contracts.md: -------------------------------------------------------------------------------- 1 | # 智能合约(Contracts) 2 | 3 | 智能合约相关的 API,接口的参数说明请参考[Etherscan API 约定](Introduction.md), 文档中不单独说明。 4 | 5 | Newly verified Contracts are synced to the API servers within 5 minutes or less 6 | 7 | ## 获取已经验证代码合约的**ABI** 8 | 9 | [Verified Contract Source Codes](https://etherscan.io/contractsVerified) 10 | 11 | ``` 12 | https://api.etherscan.io/api?module=contract&action=getabi&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=YourApiKeyToken 13 | ``` 14 | 15 | A simple sample for retrieving the contractABI using Web3.js and Jquery to interact with a contract 16 | 17 | ```js 18 | var Web3 = require('web3'); 19 | var web3 = new Web3(new Web3.providers.HttpProvider()); 20 | var version = web3.version.api; 21 | 22 | $.getJSON('http://api.etherscan.io/api?module=contract&action=getabi&address=0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359', function (data) { 23 | var contractABI = ""; 24 | contractABI = JSON.parse(data.result); 25 | if (contractABI != ''){ 26 | var MyContract = web3.eth.contract(contractABI); 27 | var myContractInstance = MyContract.at("0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359"); 28 | var result = myContractInstance.memberId("0xfe8ad7dd2f564a877cc23feea6c0a9cc2e783715"); 29 | console.log("result1 : " + result); 30 | var result = myContractInstance.members(1); 31 | console.log("result2 : " + result); 32 | } else { 33 | console.log("Error" ); 34 | } 35 | }); 36 | ``` 37 | 38 | ## 获取已经验证代码合约的**源码** 39 | 40 | ``` 41 | https://api.etherscan.io/api?module=contract&action=getsourcecode&address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413&apikey=YourApiKeyToken 42 | ``` 43 | 44 | ## [BETA] 验证源代码 45 | 46 | ``` 47 | 1. Requires a valid Etherscan APIkey, will reject if otherwise 48 | 2. Current daily limit of 100 submissions per day per user (subject to change) 49 | 3. Only supports HTTP post due to max transfer size limitations for http get 50 | 4. Supports up to 10 different library pairs 51 | 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 52 | 6. List of supported solc versions, only solc version v0.4.11 and above is supported. Ex. v0.4.25+commit.59dbf8f1 53 | 7. Upon successful submission you will receive a GUID (50 characters) as a receipt. 54 | 8. You may use this GUID to track the status of your submission 55 | 9. Verified Source Codes will be displayed at contractsVerified 56 | ``` 57 | 58 | See Demo Source Verification Submission Code at[ Source Code Verification Sample ](https://etherscan.io/sourcecode-demo.html) 59 | 60 | Source Code Submission Gist (returns a guid as part of the result upon success): 61 | 62 | ``` 63 | //Submit Source Code for Verification 64 | $.ajax({ 65 | type: "POST", //Only POST supported 66 | url: "//api.etherscan.io/api", //Set to the correct API url for Other Networks 67 | data: { 68 | apikey: $('#apikey').val(), //A valid API-Key is required 69 | module: 'contract', //Do not change 70 | action: 'verifysourcecode', //Do not change 71 | contractaddress: $('#contractaddress').val(), //Contract Address starts with 0x... 72 | sourceCode: $('#sourceCode').val(), //Contract Source Code (Flattened if necessary) 73 | contractname: $('#contractname').val(), //ContractName 74 | compilerversion: $('#compilerversion').val(), // see http://etherscan.io/solcversions for list of support versions 75 | optimizationUsed: $('#optimizationUsed').val(), //0 = Optimization used, 1 = No Optimization 76 | runs: 200, //set to 200 as default unless otherwise 77 | constructorArguements: $('#constructorArguements').val(), //if applicable 78 | libraryname1: $('#libraryname1').val(), //if applicable, a matching pair with libraryaddress1 required 79 | libraryaddress1: $('#libraryaddress1').val(), //if applicable, a matching pair with libraryname1 required 80 | libraryname2: $('#libraryname2').val(), //if applicable, matching pair required 81 | libraryaddress2: $('#libraryaddress2').val(), //if applicable, matching pair required 82 | libraryname3: $('#libraryname3').val(), //if applicable, matching pair required 83 | libraryaddress3: $('#libraryaddress3').val(), //if applicable, matching pair required 84 | libraryname4: $('#libraryname4').val(), //if applicable, matching pair required 85 | libraryaddress4: $('#libraryaddress4').val(), //if applicable, matching pair required 86 | libraryname5: $('#libraryname5').val(), //if applicable, matching pair required 87 | libraryaddress5: $('#libraryaddress5').val(), //if applicable, matching pair required 88 | libraryname6: $('#libraryname6').val(), //if applicable, matching pair required 89 | libraryaddress6: $('#libraryaddress6').val(), //if applicable, matching pair required 90 | libraryname7: $('#libraryname7').val(), //if applicable, matching pair required 91 | libraryaddress7: $('#libraryaddress7').val(), //if applicable, matching pair required 92 | libraryname8: $('#libraryname8').val(), //if applicable, matching pair required 93 | libraryaddress8: $('#libraryaddress8').val(), //if applicable, matching pair required 94 | libraryname9: $('#libraryname9').val(), //if applicable, matching pair required 95 | libraryaddress9: $('#libraryaddress9').val(), //if applicable, matching pair required 96 | libraryname10: $('#libraryname10').val(), //if applicable, matching pair required 97 | libraryaddress10: $('#libraryaddress10').val() //if applicable, matching pair required 98 | }, 99 | success: function (result) { 100 | console.log(result); 101 | if (result.status == "1") { 102 | //1 = submission success, use the guid returned (result.result) to check the status of your submission. 103 | // Average time of processing is 30-60 seconds 104 | document.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result; 105 | // result.result is the GUID receipt for the submission, you can use this guid for checking the verification status 106 | } else { 107 | //0 = error 108 | document.getElementById("postresult").innerHTML = result.status + ";" + result.message + ";" + result.result; 109 | } 110 | console.log("status : " + result.status); 111 | console.log("result : " + result.result); 112 | }, 113 | error: function (result) { 114 | console.log("error!"); 115 | document.getElementById("postresult").innerHTML = "Unexpected Error" 116 | } 117 | }); 118 | 119 | ``` 120 | 121 | Check Source code verification submission status: 122 | 123 | ``` 124 | //Check Source Code Verification Status 125 | $.ajax({ 126 | type: "GET", 127 | url: "//api.etherscan.io/api", 128 | data: { 129 | guid: 'ezq878u486pzijkvvmerl6a9mzwhv6sefgvqi5tkwceejc7tvn', //Replace with your Source Code GUID receipt above 130 | module: "contract", 131 | action: "checkverifystatus" 132 | }, 133 | success: function (result) { 134 | console.log("status : " + result.status); //0=Error, 1=Pass 135 | console.log("message : " + result.message); //OK, NOTOK 136 | console.log("result : " + result.result); //result explanation 137 | $('#guidstatus').html(">> " + result.result); 138 | }, 139 | error: function (result) { 140 | alert('error'); 141 | } 142 | }); 143 | 144 | ``` 145 | 146 | -------------------------------------------------------------------------------- /source/EventLogs.md: -------------------------------------------------------------------------------- 1 | # 事件日志 (Event Logs) 2 | 3 | 事件日志相关 API,接口的参数说明请参考[Etherscan API 约定](Introduction.md), 文档中不单独说明。 4 | 5 | [Beta] The Event Log API was designed to provide an alternative to the native eth_getLogs. Below are the list of supported filter parameters: 6 | 7 | * fromBlock, toBlock, address 8 | * topic0, topic1, topic2, topic3 (32 Bytes per topic) 9 | * 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) 10 | 11 | * fromBlock and toBlock accepts the blocknumber (integer, NOT hex) or 'latest' (earliest & pending is NOT supported yet) 12 | * Topic Operator (opr) choices are either 'and' or 'or' and are restricted to the above choices only 13 | * fromBlock and toBlock parameters are required 14 | * Either the 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 15 | * For performance & security considerations, only the first 1000 results are return. So please narrow down the filter parameters 16 | 17 | 18 | Here are some examples of how this filter maybe used: 19 | 20 | ## 通过指定区块获取日志 21 | 22 | 如获取地址为 0x33990122638b9132ca29c723bdf037f1a891a70c 区块从 379224 到最新区块 主题 topic[0] = 0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545 的事件日志的方法为: 23 | 24 | ``` 25 | https://api.etherscan.io/api?module=logs&action=getLogs 26 | &fromBlock=379224 27 | &toBlock=latest 28 | &address=0x33990122638b9132ca29c723bdf037f1a891a70c 29 | &topic0=0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545 30 | &apikey=YourApiKeyToken 31 | ``` 32 | 33 | ## 通过指定区块获取日志 34 | 35 | Get Event Logs from block number 379224 to block 400000 , where log address = 0x33990122638b9132ca29c723bdf037f1a891a70c, topic[0] = 0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545 'AND' topic[1] = 0x72657075746174696f6e00000000000000000000000000000000000000000000 36 | 37 | ``` 38 | https://api.etherscan.io/api?module=logs&action=getLogs 39 | &fromBlock=379224 40 | &toBlock=400000 41 | &address=0x33990122638b9132ca29c723bdf037f1a891a70c 42 | &topic0=0xf63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a8545 43 | &topic0_1_opr=and 44 | &topic1=0x72657075746174696f6e00000000000000000000000000000000000000000000 45 | &apikey=YourApiKeyToken 46 | ``` 47 | -------------------------------------------------------------------------------- /source/GethParityProxy.md: -------------------------------------------------------------------------------- 1 | # 节点代理(Geth/Parity Proxy) APIs 2 | 3 | 节点服务代理API,接口的参数说明请参考[Etherscan API 约定](Introduction.md), 文档中不单独说明。 4 | 5 | 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" 6 | 7 | ## 获取最近区块号 8 | 9 | 返回最近块的数量(同区块号) 10 | 11 | ``` 12 | https://api.etherscan.io/api?module=proxy&action=eth_blockNumber&apikey=YourApiKeyToken 13 | ``` 14 | 15 | ## 通过区块号查询区块信息 16 | 17 | Returns information about a block by block number 18 | 19 | ``` 20 | https://api.etherscan.io/api?module=proxy&action=eth_getBlockByNumber&tag=0x10d4f&boolean=true&apikey=YourApiKeyToken 21 | ``` 22 | 23 | ## 通过区块号查询叔块信息 24 | 25 | Returns information about a uncle by block number 26 | 27 | ``` 28 | https://api.etherscan.io/api?module=proxy&action=eth_getUncleByBlockNumberAndIndex&tag=0x210A9B&index=0x0&apikey=YourApiKeyToken 29 | ``` 30 | 31 | ## 通过区块号查询交易数量 32 | 33 | Returns the number of transactions in a block from a block matching the given block number 34 | 35 | ``` 36 | https://api.etherscan.io/api?module=proxy&action=eth_getBlockTransactionCountByNumber&tag=0x10FB78&apikey=YourApiKeyToken 37 | ``` 38 | 39 | ## 通过哈希查询交易信息 40 | 41 | Returns the information about a transaction requested by transaction hash 42 | 43 | ``` 44 | https://api.etherscan.io/api?module=proxy&action=eth_getTransactionByHash&txhash=0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1&apikey=YourApiKeyToken 45 | ``` 46 | 47 | ## 通过区块号查询交易信息 48 | 49 | Returns information about a transaction by block number and transaction index position 50 | 51 | ``` 52 | https://api.etherscan.io/api?module=proxy&action=eth_getTransactionByBlockNumberAndIndex&tag=0x10d4f&index=0x0&apikey=YourApiKeyToken 53 | ``` 54 | 55 | ## 通过地址的交易数量 56 | 57 | 可用于Nonce值 58 | Returns the number of transactions sent from an address 59 | 60 | 61 | ``` 62 | https://api.etherscan.io/api?module=proxy&action=eth_getTransactionCount&address=0x2910543af39aba0cd09dbb2d50200b3e800a63d2&tag=latest&apikey=YourApiKeyToken 63 | 64 | ``` 65 | 66 | ## 发送原始交易 67 | 68 | Creates new message call transaction or a contract creation for signed transactions 69 | 70 | 71 | ``` 72 | https://api.etherscan.io/api?module=proxy&action=eth_sendRawTransaction&hex=0xf904808000831cfde080&apikey=YourApiKeyToken 73 | ``` 74 | 75 | (Replace the hex value with your raw hex encoded transaction that you want to send. 76 | Send as a POST request, if your hex code is particularly long) 77 | 78 | ## 通过哈希查询交易收据 79 | 80 | Returns the receipt of a transaction by transaction hash 81 | 82 | 83 | ``` 84 | https://api.etherscan.io/api?module=proxy&action=eth_getTransactionReceipt&txhash=0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1&apikey=YourApiKeyToken 85 | ``` 86 | 87 | ## 执行消息调用 88 | 89 | Executes a new message call immediately without creating a transaction on the block chain 90 | 91 | 92 | ``` 93 | https://api.etherscan.io/api?module=proxy&action=eth_call&to=0xAEEF46DB4855E25702F8237E8f403FddcaF931C0&data=0x70a08231000000000000000000000000e16359506c028e51f16be38986ec5746251e9724&tag=latest&apikey=YourApiKeyToken 94 | ``` 95 | ## 获取地址代码 96 | 97 | Returns code at a given address 98 | 99 | 100 | ``` 101 | https://api.etherscan.io/api?module=proxy&action=eth_getCode&address=0xf75e354c5edc8efed9b59ee9f67a80845ade7d0c&tag=latest&apikey=YourApiKeyToken 102 | ``` 103 | ## 获取地址上某个位置的值 (体验功能) 104 | 105 | Returns the value from a storage position at a given address 106 | 107 | 108 | ``` 109 | https://api.etherscan.io/api?module=proxy&action=eth_getStorageAt&address=0x6e03d9cce9d60f3e9f2597e13cd4c54c55330cfd&position=0x0&tag=latest&apikey=YourApiKeyToken 110 | ``` 111 | ## 获取当前gas Price 112 | 113 | Returns the current price per gas in wei 114 | 115 | 116 | ``` 117 | https://api.etherscan.io/api?module=proxy&action=eth_gasPrice&apikey=YourApiKeyToken 118 | ``` 119 | ## 测量gas Limit 120 | 121 | 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 122 | 123 | 124 | ``` 125 | https://api.etherscan.io/api?module=proxy&action=eth_estimateGas&to=0xf0160428a8552ac9bb7e050d90eeade4ddd52843&value=0xff22&gasPrice=0x051da038cc&gas=0xffffff&apikey=YourApiKeyToken 126 | ``` 127 | -------------------------------------------------------------------------------- /source/Introduction.md: -------------------------------------------------------------------------------- 1 | # Etherscan API 约定 2 | 3 | 当前翻译[Etherscan官方 API](https://etherscan.io/apis)时间为**2019年4月**,因官方API没有版本号,这里用时间做一个标注。 4 | 5 | ## 包含模块 6 | 7 | Etherscan API 主要包含模块有: 8 | 9 | * 账号地址相关接口 10 | * 智能合约相关接口 11 | * 交易相关接口 12 | * 区块相关接口 13 | * 事件日志相关接口 14 | * Tokens代币相关接口 15 | * 状态相关接口 16 | * 一些相关工具相关接口 17 | 18 | 这些模块对应着左侧的一级菜单,在接口中使用`module`参数指定 19 | 20 | ## 参数 21 | 22 | 参数说明: 23 | 24 | * module: 指明接口所属模块,即上面包含的模块 25 | * action: API动作,如:txlist - 表示列出交易记录; 26 | * address: 所查询交易的账号地址; 27 | * contractaddress: 合约地址 28 | * apikey: 用户API-key 根据key来统计请求限额; 29 | * startblock: 起始查询块 id,可选,默认值为 0; 30 | * endblock: 结束查询块 id,可选,默认值为最后一个区块; 31 | * tag: 状态:pending 或 latest 32 | * blocktype: 块类型:blocks(主链块) 或 uncles (叔块) 33 | * page: 页码,可选; 34 | * offset: 每页查询记录数,可选,默认是查询 10000 条记录; 35 | * sort: 排序规则,支持正序asc和倒序desc。 36 | 37 | 38 | module、action、apikey是每个 API 都有的参数,其他的参数则因不同 API 而不同,这里做一个统一的介绍,后面介绍接口时不再单独说明。 39 | 40 | ## 测试网络接口Host 41 | 42 | 主网的Host是 **api.etherscan.io**,其实Etherscan API 所有接口在测试网络下也使用,只是所使用的域名不同,目前支持的三个网络的Host为: 43 | 44 | * api-ropsten.etherscan.io 45 | * api-kovan.etherscan.io 46 | * api-rinkeby.etherscan.io 47 | -------------------------------------------------------------------------------- /source/MiscToolsUtilities.md: -------------------------------------------------------------------------------- 1 | # 第三方工具(Utils) 2 | 3 | 4 | These are 3rd party tools and utilities created by the community and we do not provide any support or warranties for the solutions listed below 5 | 6 | ## Python API 封装 (by corpetty) 7 | 8 | ``` 9 | https://github.com/corpetty/py-etherscan-api 10 | ``` 11 | 12 | (A 3rd party EtherScan.io API python bindings module written by Corey Petty) 13 | 14 | ## node API 封装 ( by Sebastian Schürmann) 15 | 16 | 17 | ``` 18 | https:/github.com/sebs/etherscan-api 19 | ``` 20 | 21 | (A 3rd party Node API for Etherscan) 22 | 23 | ## Go API 24 | 25 | 注: 此API为译者收集 26 | 27 | ``` 28 | https://github.com/nanmu42/etherscan-api 29 | ``` 30 | 31 | ## Php 接口 32 | 33 | 注: 此API为译者收集 34 | 35 | ``` 36 | https://github.com/dzarezenko/etherscan-api 37 | ``` 38 | -------------------------------------------------------------------------------- /source/Stats.md: -------------------------------------------------------------------------------- 1 | # 常规状态数据(General Stats) 2 | 3 | 常规状态数据API,接口的参数说明请参考[Etherscan API 约定](Introduction.md), 文档中不单独说明。 4 | 5 | ## 获取以太总供应量 6 | 7 | 8 | ``` 9 | https://api.etherscan.io/api?module=stats&action=ethsupply&apikey=YourApiKeyToken 10 | ``` 11 | 12 | (Result returned in Wei, to get value in Ether divide resultAbove/1000000000000000000) 13 | 14 | ## 获取以太最新价格 15 | 16 | 17 | ``` 18 | https://api.etherscan.io/api?module=stats&action=ethprice&apikey=YourApiKeyToken 19 | ``` 20 | 21 | ## 获取节点大小(Size) 22 | 23 | [Parameters] startdate and enddate format 'yyyy-MM-dd', clienttype value is 'geth' or 'parity', syncmode value is 'default' or 'archive' 24 | 25 | 26 | ``` 27 | https://api.etherscan.io/api?module=stats&action=chainsize&startdate=2019-02-01&enddate=2019-02-28&clienttype=geth&syncmode=default&sort=asc&apikey=YourApiKeyToken 28 | ``` 29 | 30 | 返回值 chainsize 的单位是 bytes 31 | -------------------------------------------------------------------------------- /source/Tokens.md: -------------------------------------------------------------------------------- 1 | # 代币信息 Token 2 | 3 | 代币信息API,接口的参数说明请参考[Etherscan API 约定](Introduction.md), 文档中不单独说明。 4 | 5 | ## 通过合约地址获取ERC20 Token总供应量 6 | 7 | 了解[ERC20 代币定义与创建](https://learnblockchain.cn/2018/01/12/create_token/) 8 | 9 | 10 | ``` 11 | https://api.etherscan.io/api?module=stats&action=tokensupply&contractaddress=0x57d90b64a1a57749b0f932f1a3395792e12e7055&apikey=YourApiKeyToken 12 | ``` 13 | 14 | [**弃用**]Get Token TotalSupply by TokenName (Supported TokenNames: DGD, MKR, FirstBlood, HackerGold, ICONOMI, Pluton, REP, SNGLS). This has feature been deprecated, instead use the Api above to look up any ERC20 token supply by its contract address 15 | 16 | https://api.etherscan.io/api?module=stats&action=tokensupply&tokenname=DGD&apikey=YourApiKeyToken 17 | 18 | ## 获取ERC20代币余额 19 | 20 | 21 | ``` 22 | https://api.etherscan.io/api?module=account&action=tokenbalance&contractaddress=0x57d90b64a1a57749b0f932f1a3395792e12e7055&address=0xe04f27eb70e025b78871a2ad7eabe85e61212761&tag=latest&apikey=YourApiKeyToken 23 | ``` 24 | 25 | [**弃用**]Get Token Account Balance by known TokenName (Supported TokenNames: DGD, MKR, FirstBlood, ICONOMI, Pluton, REP, SNGLS). This feature has been deprecated, instead use the Api above to look up any ERC20 token balance by its contract address 26 | 27 | https://api.etherscan.io/api?module=account&action=tokenbalance&tokenname=DGD&address=0x4366ddc115d8cf213c564da36e64c8ebaa30cdbd&tag=latest&apikey=YourApiKeyToken 28 | -------------------------------------------------------------------------------- /source/Transactions.md: -------------------------------------------------------------------------------- 1 | # 交易(Transaction) 2 | 3 | 交易相关的 API,接口的参数说明请参考[Etherscan API 约定](Introduction.md), 文档中不单独说明。 4 | 5 | ## [BETA] 检查合约执行状态 6 | 7 | (if there was an error during contract execution) 8 | 9 | Note: isError":"0" = Pass , isError":"1" = Error during Contract Execution 10 | 11 | ``` 12 | https://api.etherscan.io/api?module=transaction&action=getstatus&txhash=0x15f8e5ea1079d9a0bb04a4c58ae5fe7654b5b2b4463375ff7ffb490aa0032f3a&apikey=YourApiKeyToken 13 | ``` 14 | 15 | ## [BETA] 检查交易收据状态 16 | 17 | (Only applicable for Post Byzantium fork transactions) 18 | 19 | Note: status: 0 = Fail, 1 = Pass. Will return null/empty value for pre-byzantium fork 20 | 21 | ``` 22 | https://api.etherscan.io/api?module=transaction&action=gettxreceiptstatus&txhash=0x513c1ba0bebf66436b5fed86ab668452b7805593c05073eb2d51d3a52f480a76&apikey=YourApiKeyToken 23 | ``` 24 | 25 | 26 | -------------------------------------------------------------------------------- /source/_static/z_stat.js: -------------------------------------------------------------------------------- 1 | var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1265946080'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s22.cnzz.com/z_stat.php%3Fid%3D1265946080' type='text/javascript'%3E%3C/script%3E")); 2 | -------------------------------------------------------------------------------- /source/_templates/breadcrumbs.html: -------------------------------------------------------------------------------- 1 | {%- extends "sphinx_rtd_theme/breadcrumbs.html" %} 2 | 3 | {% block breadcrumbs_aside %} 4 |
相关文档
15 |