hide You are viewing an archived web page, collected at the request of Ethereum Foundation using Archive-It. This page was captured on 17:42:40 Jun 22, 2021 , and is part of the Community collection. The information on this web page may be out of date. See All versions of this archived page. Loading media information

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.
def multiply(a):

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

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

o = c.multiply(5)


Sign In or Register to comment.