Error with Pyethereum abi_contract() importing Serpent: "Not a function or opcode: def"

I'm trying to run some very basic code with pyethereum (see below). However, I keep getting this error when trying to import the serpent code with abi_contract: "Exception: Error (file "main", line 2, char 14): Not a function or opcode: def". I'm trying to define a function with "def" so I don't understand this error. I get the same error whether I save the code inline or in a file.

Any help would be greatly appreciated!

# Import tester and utils. Initiate block.
import serpent
import ethereum.tester as t
import ethereum.utils as u
s = t.state()

# Setup test keys and addresses.
key1 = u.sha3("this is an insecure passphrase")
addr1 = u.privtoaddr(key1)

# Write contract and commit to blockchain.
serpent_code='''
def multiply(a):
return(a*2)
'''

#serpent_code = open('multiply.se').read()

c = s.abi_contract(serpent_code, sender=key1)

o = c.multiply(5)
print(str(o))

Comments

Sign In or Register to comment.