1

I'm using Nethereum and see this example of how to decode the Input data of a Transaction object. http://playground.nethereum.com/csharp/id/1063

This looks like it assumes that you have to know which function data you're decoding. I have the full contract ABI, but I don't know which function was called in this transaction.

Is there a way to decode the Input data without already knowing which function it is? In EthersJs, for example, this is done simply with a ContractInterface.parseTransaction method call.

I'm also open to suggestions for other .NET based decoding solutions/libraries.

0

This is possible but would involve some work. The first 4 bytes of that Input data is the method ID. So if you find a transaction on Etherscan then look at the input data you can find it. Method id in transaction input data

This is a hex value and is calculated by taking the method name and its argument types, removing the whitespace then generating a SHA-3 hash of the result.

So you'd first need to write code to generate hashes of the contracts method names using SHA-3, this may not be straightforward as there doesn't seem to be an implementation of it in .NET.

Once you find a way to generate the SHA-3 hashes figuring out the function would be a case of comparing the input data you are using with the generated hashes. When you have confirmed the function you can create an instance of it then call the decodeInput() method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.