Traces are available from SQD Network Portals on the same basis as all other data served there: for free, including real-time blocks. There are no surcharges for traces or state diffs.
addTrace(options)
Subscribe to execution traces. This allows for tracking internal calls. The options object has the following structure:
Item filters (where):
type: get traces of types from this set. Allowed types are 'create' | 'call' | 'suicide' | 'reward'.
callTo: get call traces to the addresses in this set.
callFrom: get call traces from the addresses in this set.
callSighash: get call traces with signature hashes in this set.
createFrom: get create traces from the addresses in this set.
suicideRefundAddress: get suicide traces where refund addresses are in this set.
rewardAuthor: get reward traces where block authors are in this set.
Filter values are matched as exact strings by the Portal — always pass addresses and sighashes as lowercase hex strings. @subsquid/evm-stream does not normalize the case for you.
Related data retrieval (include):
transaction = true: retrieve the transactions that the matching traces belong to.
transactionLogs = true: retrieve all logs emitted by transactions that the matching traces belong to.
subtraces = true: retrieve downstream traces in addition to those that matched the filters.
parents = true: retrieve upstream traces in addition to those that matched the filters.
These extra data items are added to the appropriate flat iterables within the block data. Call augmentBlock() from @subsquid/evm-objects to navigate between the related items conveniently (e.g. trace.transaction, trace.parent, trace.children).
range overrides the global setBlockRange() for this particular request.
Note that traces can also be requested by the addTransaction() and addLog() methods as related data.
Selection of the exact fields to be retrieved for each trace item is done with the setFields() method documented on the Field selection page. Be aware that field selectors for traces do not share their names with the fields of trace data items, unlike field selectors for other data item types: the action and result subfields are requested with prefixed selectors such as callTo, callSighash or createResultAddress. This is due to traces varying their structure depending on the value of the type field — see the traces section of Field selection.
Examples
Exploring internal calls of a given transaction
For a mint call to Uniswap V3 Positions NFT. Since the block range is bounded from above, run() terminates the process with exit code 0 once the range is exhausted.
Grabbing addresses of all contracts ever created on Ethereum
Requesting the error field lets us skip the traces of create operations that failed. Note that a successful create trace can still be discarded if an upstream call reverts, so a small share of the collected addresses may not correspond to live contracts.