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.1.0-rc.4.1): https://github.com/Fantom-foundation/go-opera/tree/release/txtracing/1.1.0-rc.4.1

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.
1
$ opera --genesis /path/to/genesis.g --tracenode
Copied!
Enable JSON-RPC API with option trace
1
--http.api=eth,web3,net,ftm,sfc,trace"
Copied!

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

Import, export and delete

Transaction traces are created on the node while processing transactions and then stored into node database. From version release/txtracing/1.1.0-rc.4.1 there is a possibility to export these traces and import them on other nodes. This was added to be able to react to some changes which could change content of the traces without need of doing a full sync of the blockchain again.
Another way is to delete traces, which are then recreated with next request to them from the rpc api. This option is not recomended as the recreating of the traces in this manner is slower with first request to nonexisting transaction trace.
All these operations has to be done with node which is stopped as it is changing data in the core database. For export and delete, you can specify block range, which is narrowing amount of processed transaction traces.
The command for export is export txtraces <filename.gz> <from block> <to block>
1
opera --tracenode --datadir=/path/to/opera/datadir export txtraces filename.gz 10000000 11000000
Copied!
For import it is import txtraces <filename.gz>
1
opera --tracenode --datadir=/path/to/opera/datadir import txtraces filename.gz
Copied!
With delete there is no file specified delete txtraces <from block> <to block>
1
opera --tracenode --datadir=/path/to/opera/datadir delete txtraces 10000000 11000000
Copied!

trace_block

Returns traces created at given block.
Parameters
  1. 1.
    Quantity or Tag - Integer of a block number, or the string 'earliest', 'latest' or 'pending'.
1
params: [
2
"0x22DB3E" // 2284350
3
]
Copied!
Returns
  • Array - Block traces.
Example
Request
1
curl --data '{"method":"trace_block","params":["0x22DB3E"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST https://rpcapi-tracing.fantom.network
Copied!
Response
1
{
2
"jsonrpc":"2.0",
3
"id":1,
4
"result":[
5
{
6
"action":{
7
"callType":"call",
8
"from":"0x740c82e9009738b3ab6080e89da964a4704a6cba",
9
"to":"0xd4e0aca70d1fe8979e7e1015b30a2085803d0244",
10
"value":"0x0",
11
"gas":"0x689e",
12
"input":"0x6930fd2a0000000000000000000000000000000000000000000000000000000000000608"
13
},
14
"blockHash":"0x00000ce000001cf16b859ccacc281e32e2c17730ce48b3498bf1f7f05d90fe5c",
15
"blockNumber":2284350,
16
"result":{
17
"gasUsed":"0x688f",
18
"output":"0x"
19
},
20
"subtraces":1,
21
"traceAddress":[
22
23
],
24
"transactionHash":"0x58846dd2a9fa3ea9e700838db48fd9829ebbc95e103142ac7968f658fd1ed3ac",
25
"transactionPosition":0,
26
"type":"call"
27
},
28
{
29
"action":{
30
"callType":"delegatecall",
31
"from":"0xd4e0aca70d1fe8979e7e1015b30a2085803d0244",
32
"to":"0x1125eabf1eba69ef00266b7a038141474d8afff1",
33
"value":"0x0",
34
"gas":"0x125c",
35
"input":"0x6930fd2a0000000000000000000000000000000000000000000000000000000000000608"
36
},
37
"blockHash":"0x00000ce000001cf16b859ccacc281e32e2c17730ce48b3498bf1f7f05d90fe5c",
38
"blockNumber":2284350,
39
"result":{
40
"gasUsed":"0xf62",
41
"output":"0x"
42
},
43
"subtraces":0,
44
"traceAddress":[
45
0
46
],
47
"transactionHash":"0x58846dd2a9fa3ea9e700838db48fd9829ebbc95e103142ac7968f658fd1ed3ac",
48
"transactionPosition":0,
49
"type":"call"
50
}
51
]
52
}
Copied!

trace_transaction

Returns all traces of given transaction
Parameters
  1. 1.
    Hash - Transaction hash
1
params: ["0x58846dd2a9fa3ea9e700838db48fd9829ebbc95e103142ac7968f658fd1ed3ac"]
Copied!
Returns
  • Array - Traces of given transaction
Example
Request
1
curl --data '{"method":"trace_transaction","params":["0x58846dd2a9fa3ea9e700838db48fd9829ebbc95e103142ac7968f658fd1ed3ac"],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST https://rpcapi-tracing.fantom.network
Copied!

trace_filter

Returns traces matching given filter
Parameters
  1. 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.
1
params: [{
2
"fromBlock": "0x22DB29", // 2284329
3
"toBlock": "0x22DB34", // 2284340
4
"toAddress": ["0xda7a001b254cd22e46d3eab04d937489c93174c3"],
5
"after": 20,
6
"count": 10
7
}]
Copied!
Returns
  • Array - Traces matching given filter
Example
Request
1
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
Copied!

trace_get

Returns trace at given position.
Parameters
  1. 1.
    Hash - Transaction hash.
  2. 2.
    Array - Index positions of the traces.
1
params: [
2
"0x58846dd2a9fa3ea9e700838db48fd9829ebbc95e103142ac7968f658fd1ed3ac",
3
["0x0"]
4
]
Copied!
Returns
  • Object - Trace object
Example
Request
1
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
Copied!