trace_block
方法返回指定区块中包含的所有交易的执行追踪。这提供了对单个区块内发生的所有合约交互的全面洞察。
此方法返回指定区块中所有交易的追踪数组。
区块号(十六进制区块号或 "latest"、"earliest"、"pending")
区块中所有交易的追踪对象数组
关于所采取行动的信息
调用类型(如 "call"、"delegatecall"、"staticcall")
发送者地址
为此操作提供的燃料
输入数据
接收者地址
发送的价值(以 wei 为单位)
合约初始化代码(对于创建追踪)
区块的哈希
区块号
调用结果
使用的燃料量
输出数据
创建的合约地址(对于创建追踪)
合约代码(对于创建追踪)
子追踪数量
执行追踪中的地址路径
交易的哈希
交易在区块中的索引位置
追踪类型(如 "call"、"create"、"suicide")
错误消息(如果交易失败)
响应包含区块中所有交易的追踪,每个交易可能包含多个追踪。追踪形成层次结构:
traceAddress: []
)表示初始交易traceAddress
数组,表示其在调用树中的位置subtraces
字段显示一个追踪直接子项的数量以下是追踪结构的简化可视化表示:
交易 1
├── 调用合约 A [traceAddress: []]
│ ├── 从 A 到 B 的调用 [traceAddress: [0]]
│ └── 从 A 到 C 的调用 [traceAddress: [1]]
│ └── 从 C 到 D 的调用 [traceAddress: [1, 0]]
└── 调用合约 E [traceAddress: []]
交易 2
└── ... (类似结构)
该方法返回不同类型的追踪,由 type
字段指示:
对于 type: "call"
的追踪,callType
字段表示调用类型:
如果交易或子追踪失败:
error
字段将包含原因(例如 "out of gas"、"reverted")result
字段可能为空或不完整{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"action": {
"callType": "call",
"from": "0x8bb73bcb5d553b5a556358d27625323fd781d37",
"gas": "0x576e",
"input": "0x370158ea000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"to": "0x6090a6e47849629b7245dfa1ca21d94cd15878ef",
"value": "0x0"
},
"blockHash": "0x8512d367492371edf44ebcbbbd935bc434946dddc2b126cb558df5906012186c",
"blockNumber": 1059416,
"result": {
"gasUsed": "0x14a0",
"output": "0x0000000000000000000000000000000000000000000000000000000000000001"
},
"subtraces": 0,
"traceAddress": [],
"transactionHash": "0x4c253746e8d0ab1d135df9711532c41a85ab33f069f1c733ceb0a6bf3e304503",
"transactionPosition": 0,
"type": "call"
},
{
"action": {
"callType": "call",
"from": "0x431957dbd818eaab7c5ed352430d1bf44dccd837",
"gas": "0x3d090",
"input": "0x4c37a69b00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001",
"to": "0x6090a6e47849629b7245dfa1ca21d94cd15878ef",
"value": "0x0"
},
"blockHash": "0x8512d367492371edf44ebcbbbd935bc434946dddc2b126cb558df5906012186c",
"blockNumber": 1059416,
"result": {
"gasUsed": "0x2b43",
"output": "0x0000000000000000000000000000000000000000000000000000000000000001"
},
"subtraces": 0,
"traceAddress": [],
"transactionHash": "0x1eb099b3e9396b9d188b1c313261f6a13c7e13cb5c1afd3884847cc2c61289c0",
"transactionPosition": 1,
"type": "call"
}
]
}
trace_transaction
--gcmode=archive
的 Geth 和 OpenEthereum/Nethermind)