Infura开发手册

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

eth_getTransactionByBlockNumberAndIndex

返回指定编号区块内指定序号的交易。

API请求

POST https://<network>.infura.io/v3/YOUR-PROJECT-ID

请求头:

Content-Type: application/json

请求参数:

  • BLOCK PARAMETER:区块编号或字符串标签"latest"、 "earliest" 、 "pending"
  • TRANSACTION INDEX POSITION:交易在区块内的序号,必需

请求示例:

JSON-RPC over HTTPS POST:

curl https://mainnet.infura.io/v3/YOUR-PROJECT-ID \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params": ["0x5BAD55","0x0"],"id":1}'

JSON-RPC over websockets:

wscat -c wss://mainnet.infura.io/ws/v3/YOUR-PROJECT-ID
>{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params": ["0x5BAD55","0x0"],"id":1}

API响应

返回结果为交易对象,结构如下:

  • hash:交易哈希
  • nonce:前序交易数量
  • blockHash:区块哈希
  • blockNumber:区块编号
  • transactionIndex:交易序号
  • from:交易发起地址
  • to:交易目标地址
  • value:交易金额,单位:wei
  • gasPrice:交易设定的gas价格,单位:wei
  • gas:交易量上限
  • input:交易附加数据

响应结果示例:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "blockHash": "0xb3b20624f8f0f86eb50dd04688409e5cea4bd02d700bf6e79e9384d47d6a5a35",
    "blockNumber": "0x5bad55",
    "from": "0xfbb1b73c4f0bda4f67dca266ce6ef42f520fbb98",
    "gas": "0x249f0",
    "gasPrice": "0x174876e800",
    "hash": "0x8784d99762bccd03b2086eabccee0d77f14d05463281e121a62abfebcf0d2d5f",
    "input": "0x6ea056a9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bd8d7fa6f8cc00",
    "nonce": "0x5e4724",
    "r": "0xd1556332df97e3bd911068651cfad6f975a30381f4ff3a55df7ab3512c78b9ec",
    "s": "0x66b51cbb10cd1b2a09aaff137d9f6d4255bf73cb7702b666ebd5af502ffa4410",
    "to": "0x4b9c25ca0224aef6a7522cabdbc3b2e125b7ca50",
    "transactionIndex": "0x0",
    "v": "0x25",
    "value": "0x0"
  }
}