The trace_filter
method allows you to search for specific traces within a range of blocks, filtering by various criteria such as from/to addresses, block range, and trace types. This provides a powerful way to analyze blockchain activity for specific contracts or accounts.
This method retrieves transaction traces based on the specified filter criteria.
Filter parameters
From block (hex block number or "latest", "earliest", "pending")
To block (hex block number or "latest", "earliest", "pending")
Filter traces by sender addresses (array of address strings)
Filter traces by recipient addresses (array of address strings)
Offset trace after given index
Maximum number of traces to return
Array of trace objects
Information about the action taken
Type of call (e.g., "call", "delegatecall", "staticcall")
Sender address
Recipient address
Gas provided for this part of the execution
Call data input
Value transferred in wei
Constructor initialization code (for "create" traces)
Address of the contract (for "suicide" traces)
Address receiving the refund (for "suicide" traces)
Balance of the contract at destruction (for "suicide" traces)
Hash of the block containing this trace
Block number containing this trace
Result of the call
Amount of gas used
Output data from the call
Address of the created contract (for "create" traces)
Deployed contract code (for "create" traces)
Number of subtraces
Address path of trace location in the call tree
Hash of the transaction being traced
Index position of the transaction in the block
Type of trace (call, create, suicide)
Error message if the call failed (optional)
Parameter | Type | Description |
---|---|---|
fromBlock | string | Starting block number (hex) or tag ("latest", "earliest", "pending") |
toBlock | string | Ending block number (hex) or tag ("latest", "earliest", "pending") |
fromAddress | array | Optional array of sender addresses to filter by |
toAddress | array | Optional array of recipient addresses to filter by |
after | integer | Optional pagination parameter - offset traces after the given index |
count | integer | Optional maximum number of traces to return |
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"action": {
"callType": "call",
"from": "0x8bbb73bcb5d553b5a556358d27625323fd781d37",
"to": "0x6090a6e47849629b7245dfa1ca21d94cd15878ef",
"gas": "0x12a94",
"input": "0x0000000000000000000000000000000000000000000000000000000000000000",
"value": "0x0"
},
"blockHash": "0x7eb25504e4c202cf3d62fd585d3e238f592c780cca82dacb2ed3cb5b38883add",
"blockNumber": 3928366,
"result": {
"gasUsed": "0xd979",
"output": "0x0000000000000000000000000000000000000000000000000000000000000001"
},
"subtraces": 1,
"traceAddress": [],
"transactionHash": "0x17104ac9d3312d8c136b7f44d4b8b47852618065ebfa534bd2d3b5ef218ca1f3",
"transactionPosition": 2,
"type": "call"
}
]
}
Different filter combinations can be used to answer specific questions:
To find all calls to a specific contract:
{
"toAddress": ["0x1234567890123456789012345678901234567890"]
}
To find all internal transactions from a contract:
{
"fromAddress": ["0x1234567890123456789012345678901234567890"]
}
To find interactions between two specific addresses:
{
"fromAddress": ["0x1234567890123456789012345678901234567890"],
"toAddress": ["0xabcdef0123456789abcdef0123456789abcdef01"]
}
To analyze activity within a specific block range:
{
"fromBlock": "0x429d3b",
"toBlock": "0x429d3d"
}
For large result sets, use the after
and count
parameters to paginate through results:
{ "after": 0, "count": 100, ... }
{ "after": 100, "count": 100, ... }
after
by count
valueThe method returns different types of traces:
--gcmode=archive
and OpenEthereum/Nethermind)