0

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
[0]:0000000000000000000000000000000000000000000000000000000000000000
[1]:0000000000000000000000000000000000000000000000002e8678fcd97f4000
[2]:000000000000000000000000e41d2489571d322189246dafa5ebde1f4699f498
[3]:0000000000000000000000000000000000000000000000a2a15d09519be00000
[4]:0000000000000000000000000000000000000000000000000000000000401042
[5]:000000000000000000000000000000000000000000000000000000008d64da5d
[6]:00000000000000000000000049b85d124dde84d651e0efb02f738c5e9c484a89
[7]:000000000000000000000000000000000000000000000000000000000000001b
[8]:f92d42545bd87995b4af1d3edf225dab7515a31350b755ef4761d6de160722de
[9]:3352d494554c036bd798fd287e4c2ac68371adf653a2dd6252ec7625555c1a52
[10]:00000000000000000000000000000000000000000000000000000a29e1e7c600

1 Answer 1

0

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.

2
  • Thank you! It's all making sense now. Great timing on the blog post ;-)
    – LampShade
    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
    Sep 8, 2017 at 6:39

Your Answer

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

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