I'm trying to encode the data fields according to the contract ABI using Pyethereum in python. I'm making a raw transaction. I'm successfully able send ether from one address to another by signing a transaction and then sending it raw. Now i'm trying to execute a trade function on a contract, hence the need for the data field encoding.

I feel like there should be some encode function built into Pyethereum but I cannot find it. Should I encode these manually instead? How should I go about this?

Function: trade(address tokenGet, uint256 amountGet, address tokenGive, uint256 amountGive, uint256 expires, uint256 nonce, address user, uint8 v, bytes32 r, bytes32 s, uint256 amount)

MethodID: 0x0a19b14a

1 Answer 1


I actually wrote a blog post about this a few days ago :)

The Ethereum Wiki documentation on the matter is here.

None of your inputs are of unknown length and as such it is simply a case of encoding the input arguments and padding them appropriately.

  • Thank you! It's all making sense now. Great timing on the blog post ;-)
    – LampShade
    Commented Aug 22, 2017 at 22:23
  • Link only answers are not very useful in stackexchange, if the site is down temporarily or permanently we will lost access to a good answer. Perhaps you can put the main idea here and use the link as a complement. Nice page by the way!
    – Ismael
    Commented Sep 8, 2017 at 6:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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