Retrieve Internal Transactions from a Transaction Hash
Internal transactions, also known as “subcalls” or “contract calls,” represent interactions between smart contracts during the execution of a blockchain transaction.
These transactions can be accessed using the debug_traceTransaction
method in an Ethereum-compatible RPC interface.
Using "debug_traceTransaction"
The debug_traceTransaction
method provides detailed information about all opcodes executed during the transaction. While this is comprehensive, it may be excessive if you only need internal transactions. By passing the parameter { "tracer": "callTracer" }
, you can limit the output to only the internal transactions.
Example Request
Below is an example of how to retrieve internal transactions using the debug_traceTransaction
method with the callTracer
parameter:
curl --location 'https://ethereum-mainnet.gateway.tatum.io' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {YOUR_API_KEY}' \
--data '{
"jsonrpc":"2.0",
"method":"debug_traceTransaction",
"params":["0x16c52c58916c1e91736df3242f3c85a5bb597bcc648c7a2bd05555e8d054168c",
{
"tracer":"callTracer",
"timeout": "90s"
}
],
"id":1
}'
//Response:
{
"id": 1,
"jsonrpc": "2.0",
"result": {
"from": "0x7830c87c02e56aff27fa8ab1241711331fa86f43",
"gas": "0x1e8480",
"gasUsed": "0x6bd4a",
"to": "0xa9d1e08c7793af67e9d92fe308d5697fb81d3e43",
"input": "...",
"calls": [
{
"from": "0xa9d1e08c7793af67e9d92fe308d5697fb81d3e43",
"gas": "0x15f90",
"gasUsed": "0x0",
"to": "0x9fefd35420f40222aaeafafd3721086ce381bdd5",
"input": "0x",
"value": "0x1311e50bc2c800",
"type": "CALL"
},
{
"from": "0xa9d1e08c7793af67e9d92fe308d5697fb81d3e43",
"gas": "0x15f90",
"gasUsed": "0x0",
"to": "0x147b12c06d9e8e3837280f783fd8070848d4412e",
"input": "0x",
"value": "0x143ac7788dfdcc000",
"type": "CALL"
}
// Additional internal transactions are listed here...
]
}
}
Key Fields in the Response
from
: The address initiating the internal transaction.to
: The recipient address of the internal transaction.gas
: The gas allocated for the internal transaction.gasUsed
: The gas used by the internal transaction.value
: The amount of Ether (or equivalent) transferred.type
: The type of call (e.g., CALL, DELEGATECALL).
Good to Know
- Debug and Trace methods may require access to Archival Data
- The
callTracer
is efficient for extracting internal transactions but may still be resource-intensive for large transactions. - A
Timeout
flag may be required in your request. - Find the list of supported blockchains HERE.
- Find more about available authentication methods HERE.
Updated 2 days ago