block hashes

event Error(x:str)

# Add one of the most recent 256 blocks
def add_recent(n):
   h = block.prevhash(block.number - n)
   if h == 0: 
       log(type=Error, text("block.prevhash failed"))
   else:[n] = h

# Add a block at any height, as long as we have the child
def add_old(header:str, n):
   with h =[n+1]:
    with p = sha3(header:str):
     with parent = ~calldataload(72+32):  # I don't know how calldataload works
      if h - p == 0:[n] = parent
        log(type=Error, text("sha3 hash does not match"))

# Returns the blockhash, or 0
def get_blockhash(n):
   h = block.prevhash(block.number - n)
   if h == 0: return[n]

Serpent contract for Ethereum

My Serpent code description.


Note: Your changes won't be saved, because not Logged-in.

Create your own Contract