5

If I'm talking to geth using the JSON RPC API, I've found a transaction I'm interested in and I can see that it is calling a contract (data in the 'input' part of the transaction object.)

Can I then figure out what changes to balances are as a result of this invocation? I don't see anything on the TransactionReceipt object.

2

Since you are asking about balances and have the transaction using JSON-RPC, you can see the from, to, and value of the transaction. You can make a simple guess that from's balance has decreased by value, and to's balance has increased by value.

It's a simple guess because you cannot know if the to contract sent the value to other accounts (including some back to from), unless you look more -- some examples: look at the code of the contract to see what it does, run the code through the Ethereum Virtual Machine or a simulator, or compare the differences between the current and previous block.

  • that won't show you the gas cost if one of the parties is the one that submitted the transaction. Also, in general guessing from delta numbers in distributed systems is fraught with peril. Should always use absolute counters whenever possible. Restating the original question: can we see the balance of an address at a particular transaction? – Paul S Feb 17 '16 at 21:04
  • @PaulS. Agree with your points; your question is certainly clearer and I'm not sure if that's what the question intended. Maybe it is and I think it's fine to write your answer as you perceive the question. – eth Feb 18 '16 at 8:10
  • You also could just log an event in your transaction and get the balance of whatever address you wish (address.balance in solidity). Those logs are in the receipt I believe. – Paul S Feb 18 '16 at 8:37
  • 1
    Thanks for the answers, but what specifically is not clear about my question? I know how to derive changes in balance based on the 'value' / 'gasUse' / 'gasPrice' fields from the Transaction and TransactionReceipt objects. But there can be other side effects; not just to the from or to accounts from the code in the contract itself - I'm wondering if these are exposed via JSON RPC. I don't really want to start trying to start running my own EVM to do this. But perhaps that is indeed the only way? – Jay Carey Feb 18 '16 at 21:15
  • 1
    It's not my contract - it could be any contract that I know nothing about. I'm just trying to find out what changes to balances might have occurred as a result of the call. It sounds to me like it can't be done at the moment. – Jay Carey Feb 21 '16 at 13:54

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.