2

I am learning Serpent with pyethereum in Spyder (so I have a running log of what I have tried and learned), but I am stuck in translating standard features of Serpent (such as pretty_compile) from python.

For example, how do I pretty_compile the standard multiply by 2 contract?

import serpent
from ethereum import tester, utils, abi

# Initialize tester blockchain
s = tester.state()

serpent_code = '''
def double(x):
    return(x*2)
'''

c = s.abi_contract(serpent_code) # Usual compiling

Is there a pretty_compile argument of abi_contract, or perhaps of print? I would very much like to see the opcodes for more complicated contracts within pyethereum.

3
  • Have you tried c = s.abi_contract(serpent_code, pretty_compile)? It looks like abi_contract should take general keyword arguments (I think). – Richard Horrocks Jul 6 '16 at 16:43
  • Thanks for the suggestion. I tried both your suggestion, and c = s.abi_contract(serpent_code, 'pretty_compile') but no luck. Part of the challenge is that I cannot find documentation about the arguments of abi_contract, except for the 2s preview Spyder gives me before I close the brackets. – rastapavel Jul 6 '16 at 19:03
  • You've imported tester, which contains the definition, here: github.com/ethereum/pyethereum/blob/…. I was looking at the kwargs argument, but it looks like that doesn't help. – Richard Horrocks Jul 6 '16 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.