The Code

I could have used pipermerriam’s python web3 wrapper to create the transactions and function calls and it would have been fairly straightforward. I needed something more reliable; a failed transaction means losing money. Every single one my GET requests needed a reply, even if the TCP packet got lost or the webserver on the other end was temporarily down. Therefore I decided to implement my own python etherscan API wrapper and used pythereum to create the transactions and etherscan to publish them. I also wrote my own requests.get decorator that is a while loop that only exits once the reply is satisfactory.

Here is the code I used to encode the etherdelta json API responses as hexadecimal, rlp encoded, ethereum transactions (not for the faint hearted):

The raw hexadecimal values in the closure at the bottom are the function signatures that correspond to each function. A function signature is derived from the keccak of the function and its arguments. It must be appended to the data parameter of a transaction followed by the data that makes up the arguments. In total my code is around 400 lines long and contained in 5 different files.