I'm currently trying to get a deeper understanding of how transactions in the Ethereum Blockchain work. A not so trivial example seems to track token balance of an address.
I thought about the following example: Having nothing but an address and a full node, how can I get all the transactions made by this address, including token transfers and amount of transferred tokens?
I understand that tokens are not more than mapped addresses in a smart contract (correct me if I'm wrong) and so my first thought was to just read the
balanceOf() method (assuming its ERC20 standard). But that would just give me the current amount, not all the past transactions.
So what gives me some headaches now is trying to "connect" (like wire the concept in my brain) addresses and smart contracts. How to determine if an address is a smart contract, figure out if the given address is holding (or held) tokens of that contract and if so, get the transaction history of the given address. Furthermore, is there some kind of identifier to transactions?
An example so you get what I mean:
I trade some tokens on Etherdelta (just an example, idk if it is a good one) and the I/O order to my address is not "First in, First out", how can I know which transaction belongs to which trade?
(all tokens are the same)
- I send 10 tokens(A) to Etherdelta
- I send 12 more tokens(B) to Etherdelta
- I send 3 more tokens (C) to Etherdelta
- I recieve 0.24 Eth from trade B
- I recieve 0.10 Eth from trade A
- I recieve 0.03 Eth from trade C
If you didn't already get what I was talking about, I guess you're getting it now. Even if I would be able to track all those transactions from the given address, is it possible to determine transaction pairs, like corresponding A, B and C in the example above?
Thanks for any help!