What I am struggling to achieve is the following:
- Node A sends a transaction.
- Node B starts watching for this transaction.
- When Node B sees the transaction in the latest block (ie not as a pending transaction) it updates some data in the local server and then stops watching.
- If the transaction fails (i.e it throws or runs out of gas), Node B sends an error message and stops watching.
- PS: Node B has access to the transaction hash and all the information available from the
sendTransaction( ... )callback of node A.
Would anyone please have an idea on how to achieve this? Thanks!
I am trying to allow users (the Node A in the above) to interact with a contract through a web client. When they send a transaction, I would like my server (the Node B) to start watching for it and as soon as it sees it in the latest block, add an entry with it in my database. If the transaction fails, then no entry should be added to the database. I am using meteor as my stack.
I have been thinking of having events for every transaction in my solidity contract. Then when the client sends a transaction it calls a server side method which will start watching for the event. In the event's callback, I will be checking the transactionHash to verify it matches. If it does I perform the actions described above. My issue here is what happens when the transaction fails (ie it throws or runs out of gas..) ?The correct event will never be fired of and my server will never stop watching...