[Ethereum] How to decode getData from a contract method call

calldatatransactions

I'm using myContractInstance.myMethod.getData() to be able to serialize a transaction:

// Get the call data, so you can call the contract through some other means
var myCallData = myContractInstance.myMethod.getData(param1 [, param2, ...]);
// myCallData = '0x45ff3ff6000000000004545345345345..'

The transaction is later excuted later (by another person):

web3.eth.sendTransaction({"data": myCallData});

However, I want the other person, who will execute the transaction, to be able to decode myCallData, so they know that they're not transfering a huge amount. I can't find a way to do that in the documentation, however.

Is there a friendly way to decode myCallData, and make it readable again for the user (other than breaking up the data ABI pieces myself)?

Peter.

Best Answer

The Ether value of the transaction is not part of this .getData(), it has to be set separately: web3.eth.sendTransaction({"data": myCallData, "value": 123});

On a different note, the user will need to trust the decoding tool. So why not offer a way for the user to replay this .getData() and confirm the byte-wise equality?

Related Topic