post https://polygon-mainnet-archive.allthatnode.com:8545/
The traceTransaction debugging method will attempt to run the transaction in the exact same manner as it was executed on the network. It will replay any transaction that may have been executed prior to this one before it will finally attempt to execute the transaction that corresponds to the given hash. OBS In most scenarios, debug.standardTraceBlockToFile is better suited for tracing!
Parameters
transactionHash
- the transaction hash of the transaction that needs to be traced.object
- (Optional) The tracer object with the following fields:disableStorage
:boolean
- Setting this to true will disable storage capture (default = false).disableStack
:boolean
- Setting this to true will disable stack capture (default = false).enableMemory
:boolean
- Setting this to true will disable memory capture (default = false).enableReturnData
:boolean
- Setting this to true will disable stack capture (default = false).tracer
:string
- The type of tracer. It could be callTracer or prestateTracercallTracer
- The calltracer keeps track of all call frames, including depth 0 calls, that are made during a transactionprestateTracer
- The prestateTracer replays the transaction and tracks every part of state that occured during the transaction
tracerConfig
:object
- The object to specify the configurations of the traceronlyTopCall
:boolean
- When set to true, this will only trace the primary (top-level) call and not any sub-calls. It eliminates the additional processing for each call frame
curl https://polygon-mainnet-archive.allthatnode.com:8545/8U3JLUhzIDg3GShvy9hkCCSYkLGc11kj \
--request POST \
--header "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"id": 1,
"method": "debug_traceTransaction",
"params": [
"0xf97f37d84df97202072fbe2a9e9074fc089bcce0060ee2b62c6923d8d6b178f1",
{
"enableMemory": true,
"disableStack": false,
"disableStorage": false,
"enableReturnData": true
}
]
}'
Returns
object
- trace objectfailed
- The transaction is successful or notgas
- The total consumed gas in the transactionreturnValue
- The return value of the executed contract callstructLogs
- The trace result of each step with the following fields:pc
- The current index in bytecodeop
- The name of current executing operationgas
- The available gas in the executiongasCost
- The gas cost of the operationdepth
- The number of levels of calling functionserror
- The error of the executionstack
- An array of values in the current stackmemory
- An array of values in the current memorystorage
- The mapping of the current storagerefund
- The total of current refund value
//with default tracer option
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"gas": 21045,
"failed": true,
"returnValue": "",
"structLogs": [
{
"pc": 0,
"op": "PUSH1",
"gas": 465400,
"gasCost": 3,
"depth": 1,
"stack": [],
"memory": []
},
{
"pc": 2,
"op": "PUSH1",
"gas": 465397,
"gasCost": 3,
"depth": 1,
"stack": [
"0x80"
],
"memory": []
},
{
"pc": 4,
"op": "MSTORE",
"gas": 465394,
"gasCost": 12,
"depth": 1,
"stack": [
"0x80",
"0x40"
],
"memory": []
},
{
"pc": 5,
"op": "CALLVALUE",
"gas": 465382,
"gasCost": 2,
"depth": 1,
"stack": [],
"memory": [
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000080"
]
},
//more objects
{
"pc": 14,
"op": "DUP1",
"gas": 465358,
"gasCost": 3,
"depth": 1,
"stack": [
"0x9184e72a",
"0x0"
],
"memory": [
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000080"
]
},
{
"pc": 15,
"op": "REVERT",
"gas": 465355,
"gasCost": 0,
"depth": 1,
"stack": [
"0x9184e72a",
"0x0",
"0x0"
],
"memory": [
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000080"
]
}
]
}
}
//with callTracer option
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"from": "0xe7547f9e11b48a7c6e4cfe47f267cd9fc2459464",
"gas": "0x2fa9dac",
"gasUsed": "0x224d6",
"to": "0xbb5f9ade0023ae87bdcd2268bdd74a2711654bdb",
"input": "0x520ea9dc00000000000000000000000000000000000000000000000000000000000000c8",
"output": "0x924e15fb0000000000000000000000000000000000000000000000000000000000000190",
"error": "execution reverted",
"calls": [
{
"from": "0xbb5f9ade0023ae87bdcd2268bdd74a2711654bdb",
"gas": "0x2ee972e",
"gasUsed": "0x1b55b",
"to": "0x9826309fd1925d5aa46365d5dd39c06c480384c7",
"input": "0x520ea9dc00000000000000000000000000000000000000000000000000000000000000c8",
"output": "0x924e15fb0000000000000000000000000000000000000000000000000000000000000190",
"error": "execution reverted",
"calls": [
{
//calls
}
],
"type": "DELEGATECALL"
}
],
"value": "0x0",
"type": "CALL"
}
}