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开发包
在线工具推荐: Three.js AI纹理开发包 - YOLO合成数据生成器 - GLTF/GLB在线编辑 - 3D模型格式在线转换 - 可编程3D场景编辑器

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

使用proxy模块的eth_getBlockByNumber方法获取指定编号的区块。

API调用

GET|POST /api

查询|表单参数:

  • module:proxy
  • action:eth_getBlockByNumber
  • tag:区块编号
  • boolean:是否返回交易详情,true - 返回交易详情, false - 仅返回交易哈希
  • apikey:etherscan API密钥

API返回结果

返回结果为一个JSON对象,主要字段如下:

  • jsonrpc:RPC版本号,2.0
  • id:RPC请求编号
  • result:调用结果指定编号区块的详细数据,包含以下字段:
    • difficulty:区块难度
    • extraData:额外数据
    • gasLimit:gas上限
    • gasUsed:已用gas
    • hash:区块哈希值
    • logsBloom:bloom日志
    • miner:出块账号
    • mixHash:混合哈希值
    • nonce:nonce值
    • number:
    • parentHash:父区块哈希
    • receiptsRoot:收据树根哈希
    • sha3Uncles:叔伯块sha3哈希
    • size:区块字节数
    • stateRoot:状态树根哈希
    • timeStamp:时间戳
    • totalDifficulty:到该区块为止的总难度
    • transactions:交易列表,根据参数boolean为true或false,每个交易将返回详情或交易哈希

示例代码

以curl为例的调用代码如下,也可以点击这里查看浏览器中的运行结果:

~$ curl https://api.etherscan.io/api?module=proxy&action=eth_getBlockByNumber&tag=0x10d4f&boolean=true&apikey=YourApiKeyToken

返回结果如下:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "difficulty": "0x1d95715bd14",
    "extraData": "0x",
    "gasLimit": "0x2fefd8",
    "gasUsed": "0x5208",
    "hash": "0x7eb7c23a5ac2f2d70aa1ba4e5c56d89de5ac993590e5f6e79c394e290d998ba8",
    "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
    "miner": "0xf927a40c8b7f6e07c5af7fa2155b4864a4112b13",
    "mixHash": "0x13dd2c8aec729f75aebcd79a916ecb0f7edc6493efcc6a4da8d7b0ab3ee88444",
    "nonce": "0xc60a782e2e69ce22",
    "number": "0x10d4f",
    "parentHash": "0xf8d01370e6e274f8188954fbee435b40c35b2ad3d4ab671f6d086cd559e48f04",
    "receiptsRoot": "0x0c44b7ed0fefb613ec256341aa0ffdb643e869e3a0ebc8f58e36b4e47efedd33",
    "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "size": "0x275",
    "stateRoot": "0xd64a0f63e2c7f541e6e6f8548a10a5c4e49fda7ac1aa80f9dddef648c7b9e25f",
    "timestamp": "0x55c9ea07",
    "totalDifficulty": "0x120d56f6821b170",
    "transactions": [
      {
        "blockHash": "0x7eb7c23a5ac2f2d70aa1ba4e5c56d89de5ac993590e5f6e79c394e290d998ba8",
        "blockNumber": "0x10d4f",
        "from": "0x4458f86353b4740fe9e09071c23a7437640063c9",
        "gas": "0x5208",
        "gasPrice": "0xba43b7400",
        "hash": "0xa442249820de6be754da81eafbd44a865773e4b23d7c0522d31fd03977823008",
        "input": "0x",
        "nonce": "0x1",
        "to": "0xbf3403210f9802205f426759947a80a9fda71b1e",
        "transactionIndex": "0x0",
        "value": "0xaa9f075c200000",
        "v": "0x1b",
        "r": "0x2c2789c6704ba2606e200e1ba4fd17ba4f0e0f94abe32a12733708c3d3442616",
        "s": "0x2946f47e3ece580b5b5ecb0f8c52604fa5f60aeb4103fc73adcbf6d620f9872b"
      }
    ],
    "transactionsRoot": "0x4a5b78c13d11559c9541576834b5172fe8b18507c0f9f76454fcdddedd8dff7a",
    "uncles": []
  }
}