2

There are a few questions on creating transactions and signing them offline using ethereumjs-tx. What I'm interested in is how do we build the binary data field based on the desired functionality. E.g. what is the binary data equivalent of 'execute method1 with 'foo' and 7 as arguments'?

I was planning on creating a transaction to do what I want using web3 and just stealing the bytecode from that, but it seems hacky. Any suggestions would be much appreciated!

3

Stepping into the web3 javascript functions when sending a transaction yielded some insight. Turns out the data field is made up of the following:

  • The signature of the method. This is obtained by doing a sha3 (256 bit by the looks of it) on the hex-encoded method prototype and truncating it to 8 characters.
  • The arguments to the method. These are just converted to hex format.

Both of the above are serialised into a single buffer.

From that, you could build your own transaction data using the method prototype (e.g. myMethod(uint8,uint16)).

| improve this answer | |

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.