4

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.

  • Have you looked to see if RLP might offer something? – o0ragman0o Sep 1 '16 at 13:09
  • RLP seems a bit over the top. I would follow the first example in the Contract ABI documentation, which describes how the data is encoded. – Peter de Groot Sep 9 '16 at 8:29
3

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?

  • Hi @Xavier, with 'amount' I meant a custom value from my contract, not Ethers. It seems there's no other option than decoding the data myself, but I appreciate your note on trust, and your suggestion to let the user replay getDate() and compare the output. – Peter de Groot Sep 9 '16 at 8:21

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .