Contract address - 0xfbf9ae92ecb05bc436d9b1e6c1d928824aedb2f1 - Self destructed
This contract allows participants to guess when they believe the price of ether (ETH) will next reach 500 USD. The contract is loaded with 0.5 ETH (though anyone can add more), and there are two possibilities to receive these funds.
claimCheckPriceReward()
once the oracle has set priceConfirmedOver500
to true.So bottomline, if you want to participate, call makeGuess
with your UNIX timestamp, and if you think your guess is strong relative to when we hit 500, call nominateSelfAsWinner
with your address. If you want to win the 10% prize, keep an eye on this API call (specifically, the first value of the c
array) as we approach 500 and call checkPrice
followed by claimCheckPriceReward
.
msg.sender
is the address that is making the guess and would receive the ETH.checkPrice
is called, and assuming the price is greater than 500 USD based on Kraken's last trade between the ETHUSD pairing on their API, the oracle callback function sets priceConfirmedOver500
to true and winningTimestamp
is set to the current block timestamp.checkPrice
, msg.value
of the transaction must be >= oraclePrice
(the return value of oraclize_getPrice("URL")
, currently about .004 ETH). This is because the Oraclize callback requires a fee, which is taken out of the contract balance. First call is free.winningTimestamp
is determined by the blockchain and not the instant price breaks 500 on Kraken. Thus, all functions (except selfdestruct
) can be called by anyone.checkPrice
as close as possible to when we actually pass 500USD, the first person to call claimCheckPriceReward
AFTER priceConfirmedOver500
is set to true by the oracle is rewarded 10% of the contract's current totalAmount
. To be clear, the person who gets the reward is not the person who called checkPrice
but the person who called claimCheckPriceReward
after priceConfirmedOver500
is set to true by the oracle. The reason for this is because there are possible gas errors by having the oracle __callback
call other functions that change state.winningTimestamp
.winningTimestamp
is established by the oracle. payout
can be called by anyone following this seven day period, and the address who got closest to winningTimestamp
takes all that remains in totalAmount
. It doesn't matter if you guessed over or below winningTimestamp
, it's all about who is closest.lowestDiff
relative to winningTimestamp
(i.e., there will not be multiple winners or a tie). I experimented a little with a few ways of checking for/implementing this and just let it be. In this unique situation, the contract logic is such that the last address nominated during the nomination period would be set as winner
.owner
can call in the event that there is some unforeseen logic error or if Kraken's API changes. The address hard-coded in the contract is for the nonprofit Give Directly (proof), who would receive the contract balance if this function is called.at Address
. This should allow you to interact with the various functionsThese contracts evolved during the testing period, and differed (in terms of the variables) only by setting the threshold lower for ETHUSD price (relative to current market price) and eliminating the amount of time to elapse to call certain functions.
This is an open source project. Contributions are welcomed & encouraged! :smile: