4

I'm analyzing interactions between accounts in Ethereum. I started by external transactions (sent from accounts), but wanted to extend the analysis to external ones (resulting from smart contract execution). For instances, if there's a transaction invoking a smart contract function paying several accounts (from an internal contract list), I'd like to extract those accounts. E.g., in this contract, I'd like to extract the accounts being paid in transaction invoking payAll().

Following this thread, I set up Parity in archive mode (--pruning=archive) and tried to use traceReplayTransaction in different modes. However, I'm still not able to get the accounts from the output.

I've also tried ethereum-input-decoder, but it only provides me with accounts provided as as arguments to smart contract functions.

This paper suggests that I should extract CREATE, CALL, CALL-CODE, DELEGATE-CALL and SELFDESTRUCT EVM operations, but I'm not sure what's the easiest way to do that.

Any help will be highly appreciated!

EDIT: Thank you for all the answers. To get the required information, I've set up parity in archive mode (--pruning archive) and called trace_replayTransaction in stateDiff mode on each transaction. This method should work on other clients as long as they implement the RPC call. An important note when running parity in dev mode is that, in my case, it was not showing the last submitted transaction, so make sure that you submit a new transaction after the one you want to observe.

2

You'll need to actually go through and parse the JSON to get that. Specifically the action block.

See the JSONRPC call trace_replayTransaction here: https://openethereum.github.io/JSONRPC-trace-module

You'll find the addresses you are looking for in those responses.

4
  • Thank you! I now use trace_replayTransaction in all 3 modes (trace, VMTrace, stateDiff) and I can easily extract from/to in the action block. I'm just wondering if this block gives me all the involved addresses? E.g., if in a contract, I call a function without any parameters and it executes some_address.transfer(), will some_address be shown in the action block? When using VMTrace mode, I see a lot of data in the ops section, also including some address-like strings (0x + 64 chars), but not sure if those are actual address that I should extract using some regular expressions.
    – harnen
    Mar 31 at 8:32
  • Yes and no. If you only want ETH-denominated sends/recieves, then yes. Otherwise for ERC20s and the like you'll need to dive into the "input" field and decode using the ABI for that particular contract. You can also pull the logs and check that way. Apr 2 at 5:12
  • @harnen if this answered your question, please mark it as answered! :) Apr 7 at 6:06
  • Sorry for the delay. If I understand correctly, parsing the input field will catch only accounts submitted in the transaction, but will omit accounts that are already in the contract (say set up in the constructor, or submitted before)? In any case, tomorrow I plan to set up a custom smart contract with all the possible ways of storing and interacting with the accounts and see whether I can grab everything from trace_replayTransaction. The next thing I do, is to come here to report and (hopefully) mark as resolved :)
    – harnen
    Apr 8 at 8:13
1

Usually Events are used to achieve this (since decoding the transaction data is rather cumbersome). The smart contract you linked to as an example unfortunately has no events, but since it seems to be your code, it might be worth considering to add them.

ERC20 tokens for example emit Transfer events, when tokens change the owner. There you can find from- and to-addresses, as well as the transferred value. Sites like Etherscan process events to display (some) internal transactions. Maybe this approach is viable for you, too.

1
  • Thanks! Yes, events would be definitely easier, but I'd like to analyze the whole Ethereum history trying to see the object interactions (i.e., not only my contract), so probably won't be able to convince all the Smart Contract developers to cooperate for my project :)
    – harnen
    Apr 9 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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