Transaction tracing API

Transaction tracing enables deeper look into smart contract inner calls and account creation calls. It is inspired with the OpenEthereum (Parity) node trace module, which is used in lot of projects.

For now, following JSON-RPC methods are implemented:

  • trace_block

  • trace_filter

  • trace_get

  • trace_transaction

Currently it is deployed on endpoints for Fantom mainnet and testnet:

Installing own go-opera tracing node

Because of stored traces, size of data needed for this kind of node is little bit bigger (around 1/4 more). For more information, please follow README.md file in txtracing branch.

Building

You have to build release version from git repository (release/txtracing/1.0.1-rc.2): https://github.com/Fantom-foundation/go-opera/tree/release/txtracing%2F1.0.1-rc.2

Running

It's recommended to launch new node from scratch with CLI option --tracenode as this flag has to be set to use stored transaction traces.

$ opera --genesis /path/to/genesis.g --tracenode

Enable JSON-RPC API with option trace

--http.api=eth,web3,net,ftm,sfc,trace"

Tracing pre-genesis blocks

If you want to use tracing for pre-genesis blocks, you'll need to import evm history. You can find instructions here: importing evm history

trace_block

Returns traces created at given block.

Parameters

  1. Quantity or Tag - Integer of a block number, or the string 'earliest', 'latest' or 'pending'.

params: [
"0x22DB3E" // 2284350
]

Returns

  • Array - Block traces.

Example

Request

curl --data '{"method":"trace_block","params":["0x22DB3E"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST https://rpcapi-tracing.fantom.network

Response

{
"jsonrpc":"2.0",
"id":1,
"result":[
{
"action":{
"callType":"call",
"from":"0x740c82e9009738b3ab6080e89da964a4704a6cba",
"to":"0xd4e0aca70d1fe8979e7e1015b30a2085803d0244",
"value":"0x0",
"gas":"0x689e",
"input":"0x6930fd2a0000000000000000000000000000000000000000000000000000000000000608"
},
"blockHash":"0x00000ce000001cf16b859ccacc281e32e2c17730ce48b3498bf1f7f05d90fe5c",
"blockNumber":2284350,
"result":{
"gasUsed":"0x688f",
"output":"0x"
},
"subtraces":1,
"traceAddress":[
],
"transactionHash":"0x58846dd2a9fa3ea9e700838db48fd9829ebbc95e103142ac7968f658fd1ed3ac",
"transactionPosition":0,
"type":"call"
},
{
"action":{
"callType":"delegatecall",
"from":"0xd4e0aca70d1fe8979e7e1015b30a2085803d0244",
"to":"0x1125eabf1eba69ef00266b7a038141474d8afff1",
"value":"0x0",
"gas":"0x125c",
"input":"0x6930fd2a0000000000000000000000000000000000000000000000000000000000000608"
},
"blockHash":"0x00000ce000001cf16b859ccacc281e32e2c17730ce48b3498bf1f7f05d90fe5c",
"blockNumber":2284350,
"result":{
"gasUsed":"0xf62",
"output":"0x"
},
"subtraces":0,
"traceAddress":[
0
],
"transactionHash":"0x58846dd2a9fa3ea9e700838db48fd9829ebbc95e103142ac7968f658fd1ed3ac",
"transactionPosition":0,
"type":"call"
}
]
}

trace_transaction

Returns all traces of given transaction

Parameters

  1. Hash - Transaction hash

params: ["0x58846dd2a9fa3ea9e700838db48fd9829ebbc95e103142ac7968f658fd1ed3ac"]

Returns

  • Array - Traces of given transaction

Example

Request

curl --data '{"method":"trace_transaction","params":["0x58846dd2a9fa3ea9e700838db48fd9829ebbc95e103142ac7968f658fd1ed3ac"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST https://rpcapi-tracing.fantom.network

trace_filter

Returns traces matching given filter

Parameters

  1. Object - The filter object

    • fromBlock: Quantity or Tag - (optional) From this block.

    • toBlock: Quantity or Tag - (optional) To this block.

    • fromAddress: Array - (optional) Sent from these addresses.

    • toAddress: Address - (optional) Sent to these addresses.

    • after: Quantity - (optional) The offset trace number

    • count: Quantity - (optional) Integer number of traces to display in a batch.

params: [{
"fromBlock": "0x22DB29", // 2284329
"toBlock": "0x22DB34", // 2284340
"toAddress": ["0xda7a001b254cd22e46d3eab04d937489c93174c3"],
"after": 20,
"count": 10
}]

Returns

  • Array - Traces matching given filter

Example

Request

curl -H "Content-Type: application/json" -X POST --data '{"method":"trace_filter","params":[{"fromBlock":"0x22DB29", "toBlock":"0x22DB34", "fromAddress":["0xda7a001b254cd22e46d3eab04d937489c93174c3"], "count":10, "after":20}],"id":1,"jsonrpc":"2.0"}' https://rpcapi-tracing.fantom.network

trace_get

Returns trace at given position.

Parameters

  1. Hash - Transaction hash.

  2. Array - Index positions of the traces.

params: [
"0x58846dd2a9fa3ea9e700838db48fd9829ebbc95e103142ac7968f658fd1ed3ac",
["0x0"]
]

Returns

  • Object - Trace object

Example

Request

curl -H "Content-Type: application/json" -X POST --data '{"method":"trace_get","params":["0x58846dd2a9fa3ea9e700838db48fd9829ebbc95e103142ac7968f658fd1ed3ac",["0x0"]],"id":1,"jsonrpc":"2.0"}' https://rpcapi-tracing.fantom.network