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场景编辑器

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

使用account模块的txlist方法,可以获取指定地址的普通交易清单。

API调用

GET|POST /api
  • HTTP方法:GET/POST
  • URI:/api
  • 查询参数:
    • module:account
    • action:txlist
    • address:要查询交易清单的以太坊地址
    • apikey:你的etherscan API令牌
    • startblock:起始区块号,可选
    • endblock:结束区块号,可选
    • page:结果页号,可选
    • offset:每页交易数量,可选
    • sort:排序,asc为升序,desc为降序,可选

API返回值

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

  • status:状态码,1为成功
  • message:调用描述信息,OK为成功
  • result:调用结果数组,每个成员描述一个交易,包含如下字段:
    • blockNumber:区块编号
    • timeStamp:区块时间戳
    • hash:交易哈希
    • nonce:nonce值
    • blockHash:区块哈希值
    • from:发起账号
    • to:接收账号
    • value:交易金额
    • gas:gas用量
    • gasPrice:gas价格
    • isError:是否发生错误,0表示没有错误,1表示发生错误
    • txreceipt_status:交易收据状态
    • input:交易附加数据,16进制字符串编码
    • contractAddress:合约地址
    • cumulativeGasUsed:区块累计交易用量
    • gasUsed:本交易的gas用量
    • confirmations:交易确认数

注意,单次调用最多返回10000个交易。

调用示例

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

~$ curl http://api.etherscan.io/api?module=account&action=txlist&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&startblock=0&endblock=99999999&sort=asc&apikey=YourApiKeyToken

返回值:

{
    "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"
    }]
}

也可以使用page和offset查询参数获取分页结果,例如获取第一页的10个交易:

~$ curl https://api.etherscan.io/api?module=account&action=txlist&address=0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a&startblock=0&endblock=99999999&page=1&offset=10&sort=asc&apikey=YourApiKeyToken