Last Will and Testament

# Last Will & Testament using a "dead-man's-switch"
# If the contract isn't touched by the creator at least once per month, he's dead
# Therefore, split all funds among the heirs

  # On contract creation, record the creator["CREATOR"] = tx.origin
  # A future transaction received from the creator does three things:
  #     1) It's proves he's alive and supresses distribution for another 30 days
  #     2) It naturally increases the contract's balance by the amount of the transaction value
  #     3) It optionally supplies a new list of heirs
  if tx.origin ==["CREATOR"]:
    # Here we record the time of this touch by the creator. He's still alive.["LAST_TOUCH"] = block.timestamp
    if msg.datasize > 0:
      # The creator defines heirs by supplying their payment addresses as (padded 32-byte) inputs to the contract
      # He can change these by supplying a new set of addresses which replaces all of the old set
      while i <= msg.datasize:
        # each heir will be recorded for future reference in the storage range 1000+
        i = (i + 1)[(1000 + i)] =[i-1]
      while i <=["HEIR_COUNT"]:
        # any extra former heirs are removed
        i = (i + 1)[(1000 + i)] = 0
      # remember how many heirs we have for later["HEIR_COUNT"] = msg.datasize
    # A transaction received by anyone else triggers distribution to heirs if we haven't heard from the creator
    # (there are 2,592,000 seconds in a month)
    if block.timestamp > (["LAST_TOUCH"] + 2592000):
      # calculate the equal portion for each heir
      PORTION = (contract.balance /["HEIR_COUNT"])
      # distribute the portions out to the heirs
      while i <["HEIR_COUNT"]:
        send([(1000 + i)], PORTION, (tx.gas - 100))
        i = (i + 1)

Serpent contract for Ethereum

My Serpent code description.


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

Create your own Contract