Transaction tracing API

Experimental, work in progress

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_transaction

It can be called on go-lachesis node with rpc turned on and with rpc feature "trace" on as well. For now the source code is fork based on go-lachesis v0.8.1-rc.4 and can be found on following link in branch feature/transaction-tracing:

Currently it is deployed on staging environment connected to Fantom mainnet, so you can try to interact with it on address https://rpcapi-staging2.fantom.network/‚Äč

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-staging2.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-staging2.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-staging2.fantom.network