Using the web3 JS library, there's hooks to grab a transaction by its hash (web3.eth.getTransaction()
), which includes an input
property that is the data payload of the transaction. The first four bytes of which are the function selector which is a fragment of a hash.
The question is, how to determine what function was called? Hashes can't be worked backwards, so we need to derive the list of function signatures for that contract (a.k.a. the contract ABI).
Web3 has the web3.eth.getCode(txnHash)
method that can get the hex code for a contract, but can that be parsed into an ABI of the contract?
Or is it impossible to derive the ABI without having the source code of the contract?