Newbie help: why won't this contract compile?

CosmicSerpentCosmicSerpent Member Posts: 3
edited September 2015 in Serpent
I decided to test out a proof-of-concept for what I figure would be the ideal application of contract programming -- a bounty for finding large prime numbers. I put together this quick-and-dirty implementation in Etherscripter and then tidied it up by hand.

But why won't it compile?

init: data bounty = msg.data[0] data minimum = msg.data[1] data killswitch = msg.sender data results[] code: if tx.origin == self.killswitch: # Shutting down contract. suicide(self.killswitch) else: candidate = msg.data[0] if (candidate % 2) == 0 or candidate < self.minimum or (self.results[candidate] % 2) == 1 or self.results[candidate] == candidate: # This number is too small, even, or has already been tested. stop else: if self.results[candidate]: # Even number in storage means restore previous progress. factor = (self.results[candidate] + 1) else: factor = 3 while (factor * factor)

Also, is there a way to get a more useful error message than this -- say, one that points to a specific line of Serpent code?
$ serpent compile primebounty.se
compile ['primebounty.se'] {}
Error (file "main", line 1, char 0): Invalid argument count or LLL function: (init (seq (data (set 'bounty (mload (. (get 'msg) (get 'data))))) (data (set 'minimum (mload (add (. (get 'msg) (get 'data)) 32)))) (data (set 'killswitch (caller)))))
Traceback (most recent call last):
File "/usr/local/bin/serpent", line 9, in
load_entry_point('ethereum-serpent==2.0.1', 'console_scripts', 'serpent')()
File "/usr/local/bin/serpent.py", line 225, in main
o = globals()[cmd](*args, **kwargs)
File "/usr/local/bin/serpent.py", line 92, in
compile = lambda code, **kwargs: pyext.compile(strtobytes(pre_transform(code, kwargs)))
Exception: Error (file "main", line 1, char 0): Invalid argument count or LLL function: (init (seq (data (set 'bounty (mload (. (get 'msg) (get 'data))))) (data (set 'minimum (mload (add (. (get 'msg) (get 'data)) 32)))) (data (set 'killswitch (caller)))))
Post edited by CosmicSerpent on

Comments

Sign In or Register to comment.