🟪 Polygon
trace_replayTransaction

Polygon API Documentation


trace_replayTransaction RPC Method

trace_replayTransaction executes the transaction with the given hash and returns traces. Ideal for simulations and blockchain analysis.

Parameters

1.TRANSACTION HASH [required]

The hash of the transaction to be traced.

2.TRACE TYPE [required]

  • array - The type of traces to include

    • vmTrace - Include the full trace of the virtual machine during the transaction

    • trace - Include the basic trace of the transaction

    • stateDiff - Include state changes caused by the transaction

🔌 To use trace_replayTransaction you must be connected to a blockchain node.

Returns

  • object - The trace object.

    • output - The output (return value) of the call.

    • stateDiff - The state changes that would happen due to the transaction in the given eth_call.

    • trace - The trace of the call.

      • action - The action to be performed.

        • from - The address of the sender.

        • callType - The type of method such as call, delegatecall.

        • gas - The gas provided by the sender.

        • input - The input data of the call or delegatecall.

        • to - The address of the receiver.

        • value - The amount of ETH sent with this transaction.

      • result - The result of the transaction.

        • gasUsed - Gas used by the transaction.

        • output - The return value of the call. Can be empty.

      • subtraces - The traces of internal transactions (calls made by the contract)

      • traceAddress - The list of addresses where the call was executed, the address of the parents and the order of the current sub call.

      • type - The value of the method such as call or create.

    • vmTrace - The full trace of the virtual machine's state during execution of the given eth_call, including any sub-calls.

Request

POST https://<network>.chainnodes.org/YOUR-API-KEY

Example

💡 Confusing?

Ask our experienced blockchain developers in Telegram

  • HTTPS POST Request with a JSON RPC call in the body
  • Replace YOUR-API-KEY with the API key from your CHAINNODES.ORG Dashboard
  • You can use a different supported network by replacing polygon-mainnet
curl https://polygon-mainnet.chainnodes.org/YOUR-API-KEY \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"method":"trace_replayTransaction","params":["0xe4c5d1d7b31082c2740ceaa012bd5aa5c766954eda71ea2e04c164505eacd58b", ["stateDiff"]],"id":1,"jsonrpc":"2.0"}'

Body

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
        "output": "0x",
        "stateDiff": {
            "0x25d4e7fe624fcc6e7f0b52d142f40c9acecf039a": {
                "balance": "=",
                "code": "=",
                "nonce": "=",
                "storage": {
                    "0x259c4f37dd4adabfe26f9e16f66f499803bb6cb86ee7bc0de6ec3188eb5cbdb1": {
                        "*": {
                            "from": "0x00000000000000000000000000000000000000004986e0a07ed6d812e1291938",
                            "to": "0x00000000000000000000000000000000000000004918295544248067e96a0821"
                        }
                    },
                    "0xd3150d3c6b025ddd7cf16c5e3110845e856be3c04ce72ac0d809d8a6ff5b7fbf": {
                        "*": {
                            "from": "0x0000000000000000000000000000000000000000007a8878e0279a3b48b2d1e3",
                            "to": "0x0000000000000000000000000000000000000000008011a3097d51d0a1e2c5f0"
                        }
                    },
                    "0xf46977dca8de7b6f1a07dbf25387f185795e9de998f43ab920b3e9774e80509f": {
                        "*": {
                            "from": "0x000000000000000000000000000000000000000001676189b52a029e53bc9d58",
                            "to": "0x000000000000000000000000000000000000000001d08faac686a2b3f24bba62"
                        }
                    }
                }
            },
            "0x73b66a14599ec4741a855fc25da0e1664a3bd44a": {
                "balance": "=",
                "code": "=",
                "nonce": "=",
                "storage": {
                    "0x0000000000000000000000000000000000000000000000000000000000000008": {
                        "*": {
                            "from": "0x642ee02b000000000000e9d8723170a9438900004986e0a07ed6d812e1291938",
                            "to": "0x642ee1f3000000000000eb3bb7a9ce33438900004918295544248067e96a0821"
                        }
                    },
                    "0x0000000000000000000000000000000000000000000000000000000000000009": {
                        "*": {
                            "from": "0x0000000000000000000000000000000000000467e6da044800a4f5c4f32076c0",
                            "to": "0x0000000000000000000000000000000000000467ec84487d32d8650200d81128"
                        }
                    },
                    "0x000000000000000000000000000000000000000000000000000000000000000a": {
                        "*": {
                            "from": "0x000000000000000000000004db5445dad8caa0bcc2dd1f1671303e206337a048",
                            "to": "0x000000000000000000000004dbe3a691d87b9eed03d49506bc8da76df7667948"
                        }
                    }
                }
            },
            "0xbcfb2202cb0f589023bde3b26c7c8fed231fbd68": {
                "balance": {
                    "*": {
                        "from": "0x1a1a178a1062540",
                        "to": "0x2d3f05f33f617b"
                    }
                },
                "code": "=",
                "nonce": {
                    "*": {
                        "from": "0xa3",
                        "to": "0xa4"
                    }
                },
                "storage": {}
            },
            "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2": {
                "balance": {
                    "*": {
                        "from": "0x313c95019de213422b214",
                        "to": "0x313c9517d239991acb214"
                    }
                },
                "code": "=",
                "nonce": "=",
                "storage": {
                    "0xfec8bfeec3842afe33b05cd67739ce2e22ce955f3bc5307e285bc035ca7a5d09": {
                        "*": {
                            "from": "0x000000000000000000000000000000000000000000000000e9d8723170a94389",
                            "to": "0x000000000000000000000000000000000000000000000000eb3bb7a9ce334389"
                        }
                    }
                }
            },
            "0xdb6950e1029a7734b74508ffe11cc6665d6e6486": {
                "balance": {
                    "*": {
                        "from": "0x637413f944df49",
                        "to": "0x637f51e0984429"
                    }
                },
                "code": "=",
                "nonce": "=",
                "storage": {}
            }
        },
        "trace": [],
        "vmTrace": null
    }
}

Need RPC API keys?

Get 12.5M archival requests for free today.

JSON-RPC Polygon API Documentation by CHAINNODES is based on Erigon node client. Contact us if you are interested in specific methods that are only available on geth, besu, Nethermind or reth