When working on one of my projects, it was asked “How do we ensure that transaction was indeed recorded on the blockchain”
While we can (and did) store the transaction hash returned by the function call
in the database,
txn_hash alone does no good.
e.g. “Official” method to get the details of the transaction (from the
txn_hash) returns something like the following:
It doesn't really mean much - even to the developers. Sure
addresses provide some useful data, but we don't know what “operation” was
performed and with what data. (The data is in the
input field shown above, but
does not make sense “as-is”)
What if you could see something like the following, instead ?
You get the function name, not an address, and the parameters passed to the function - which can be “somewhat” useful, depending on the the types of parameters.
e.g. in the above sample, the first input param is the address and the second one - a number.
It may be easy to guess (from the function name) that we are minting 0x64 i.e. 100 tokens for a given address.
Isn't that much better ?
Getting such “human readable” output is made possible by
ethereum-input-data-decoder library - which does the heavy lifting
I added some wrapper functionality to make it as generic as possible without having to make code changes.
You can pass the
txn_hash and the path to the JSON file created by
truffle compile as arguments to the script.
Thus it works for any contract.
You can see the source code here
If you have any queries (about the code) feel free to file a github issue (or ask here in comments)