1

In etherscan I noticed that there are transactions that have "internal transactions" inside of them, see this link: etherscan transaction.

Screenshot of the transaction: enter image description here

My question is: how can I find these internal transactions using the JSON-RPC methods? I tried both the method 'eth_getBlockByNumber' and the method 'eth_getTransactionReceipt' but I don't see these info:

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0x893c428fed019404f704cf4d9be977ed9ca01050ed93dccdd6c169422155586f"],"id":1}' https://cloudflare-eth.com | jq

curl -sX POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","id":1,"method":"eth_getBlockByNumber","params":["0xC3BF", true]}' https://cloudflare-eth.com | jq

1 Answer 1

2

You need to use debug_traceTransaction. This method allows you to get all opcodes executed by the transaction, but if you need only the internal transactions it can be overkill. Luckily you can pass the parameter {"tracer":"callTracer"} to get only those.

curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"debug_traceTransaction","params":["0x893c428fed019404f704cf4d9be977ed9ca01050ed93dccdd6c169422155586f", {"tracer":"callTracer"}],"id":1}' https://eth.llamarpc.com | jq

It will print the following result, with the internal transactions listed in "calls":

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "from": "0xfd2605a2bf58fdbb90db1da55df61628b47f9e8c",
    "gas": "0x2bb38",
    "gasUsed": "0x195b2",
    "to": "0x109c4f2ccc82c4d77bde15f306707320294aea3f",
    "input": "0x",
    "calls": [
      {
        "from": "0x109c4f2ccc82c4d77bde15f306707320294aea3f",
        "gas": "0x8fc",
        "gasUsed": "0x0",
        "to": "0x881b0a4e9c55d08e31d8d3c022144d75a454211c",
        "input": "0x",
        "value": "0xde0b6b3a7640000",
        "type": "CALL"
      }
    ],
    "value": "0xde0b6b3a7640000",
    "type": "CALL"
  }
}

Docs: https://geth.ethereum.org/docs/developers/evm-tracing/built-in-tracers#call-tracer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.