3

I'm trying to simulate a transaction without actually sending the transaction. The trace_call method (on Alchemy) returns 3 types of traces - vmTrace, trace, stateDiff. The trace object returns all the call, staticall and delegatecall in the entire transaction. It also provides calldata and return values for all these internal calls. Example trace for the transaction 0x1dafb48e048b11ee1c6e1ce754eface63c632f9e8b79c159290964bbee9d110f on kovan.

{
  "action": {
    "callType": "call",
    "from": "0x6303e43320b036084a539d622a996e56c2110a16",
    "gas": "0x1af6",
    "input": "0xd0e30db0",
    "to": "0xd0a1e359811322d97991e03f863a0c30c2cf029c",
    "value": "0xb1a2bc2ec50000"
  },
  "result": {
    "gasUsed": "0x1af6",
    "output": "0x"
  },
  "subtraces": 0,
  "traceAddress": [],
  "type": "call"
}

But this doesn't return way logs. One way to do this, is to parse the vmTrace that provides the stack push and memory updates at each opcode's execution. It looks something like this.

{
  "cost": 3,
  "ex": {
    "mem": null,
    "push": [
      "0x40"
    ],
    "store": null,
    "used": 6896
  },
  "pc": 2,
  "sub": null
}

But since we don't know what opcode is being executed at a particular program counter, we'll need to rerun the transaction locally on an evm to keep track of when the log[0-4] opcodes are run and capture the stack value at that time. But running an evm just to parse out logs seem excessive. Is there an alternative for this? Geth's debug_transaction offers this but there isn't any API that provides access to it.

Is there any other way to get the logs for a transaction without actually sending the transaction?

1 Answer 1

0

This article by Banteg may be helpful: https://banteg.mirror.xyz/vZySVJ4Wvf4tKhgskbEIcHAlqG20wifUy807bzfEsp8

Otherwise, you will have to fork using ganache/anvil and send the transaction or simulate locally using some other method.

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.