CoinFlip

Loading...
# the 50/50 double or nothing contract
init:
  # my address
  contract.storage["ADMIN"] = "0xf446a86b861db952897ac58abe8f11cda0235fea"
code:
  # minimum bet is 1000X basefee. Refunds lower bets less tx cost
  if tx.value < 1000 * block.basefee:
    send(tx.origin, (msg.value - tx.gas), tx.gas)
    stop
  # the address of the contract caller
  contract.storage["gambler"] = msg.sender
  # 1% fee to cover gas and because the house always wins
  contract.storage["bet"] = (msg.value * 0.99)
  # take mod 2 of the block time and if result is 0 (i.e. if time in seconds is an even number) then trigger the payout
  if block.timestamp % 2:
      send(tx.origin, (contract.storage["bet"] * 2), (tx.gas - 100))

Serpent contract for Ethereum

My Serpent code description.

Preferences

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

Create your own Contract