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

  1. When Student enters the credential in the form, the state is OPEN.
  2. When college registers the student against its credentials, state is REGISTERED.
  3. 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 Dec 8, 2016 at 19:18
  • @TjadenHess I see. Are you saying that we keep the logs out of chain? Say and external db?
    – niksmac
    Dec 9, 2016 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 Dec 9, 2016 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.
    – niksmac
    Dec 23, 2016 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.

  • I think OP is asking for on demand solution from the chain itself.
    – niksmac
    Dec 9, 2016 at 1:55

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.