I have a smart contract of Student Registration. The state changes in the following manner:

When Student enters the credential in the form, the state is OPEN.

When college registers the student against its credentials, state is REGISTERED.

When payment of fee is done, state becomes PAID.

Here, after every action, i.e registration or payment, i receive a transaction hash of the transaction. How can i trace all the states of this process with transaction hash only. This is also called as Audit trail. How can i accomplish this in solidity or ethereum?

Do you need it to be the transaction hash only, or can you use events? Events are the clean and recommended way of implementing something like this
– Tjaden Hess♦Dec 8 '16 at 19:18

@TjadenHess I see. Are you saying that we keep the logs out of chain? Say and external db?
– niksmacDec 9 '16 at 4:45

1

The logs are part of the chain, you can always fetch the past ones directly from your client. It may be helpful to store a database for faster lookups, but events are logged and stored as part of the consensus protocol
– Tjaden Hess♦Dec 9 '16 at 5:04

It is a good practice that accepting the answer as correct if it helped you resolved the issue. That is the whole point of SE none of the answers for your questions are marked as correct. FYI, if youre not aware of it.
– niksmacDec 23 '16 at 2:53

1 Answer
1

In the contract code itself you should have already placed 'events' at each point where you wish to track state changes. Then, you would use a web3.js filter to watch for the events on your calendar (sorry, I don't have a link to that code, but it would most likely involve the use of this RPC function: https://github.com/ethereum/wiki/blob/master/JSON-RPC.md#eth_newfilter).

If you don't have events already built into your smart contract, you could pull down transactions from a block explorer such as http://etherscan.io using their API functionality, but then you would have to post process and be careful to account for in-error transactions and internal transactions.