I have been trying to deploy and test the basic "SimpleDice" smart contract provided as an example from Oraclize.
I have had to adjust it to work with solidity 0.4.2 a bit, but maybe I am missing something, maybe Oraclize is bugging out.
The smart contract can be found here: https://testnet.etherscan.io/address/0xe1b0d1eecc126b96f94cf55e6cf525ccae4bf0d8
EDIT: I have also deployed a second contract at https://testnet.etherscan.io/address/0xe25229cc19b5044f7cbe0c20abf9972c77b1e36c with more balance, this fixes the invalid jumps however I STILL see no callbacks being executed
I have the following code (note, usingOraclize.sol is the file located at https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.4.sol ):
pragma solidity ^0.4.2;
import "usingOraclize.sol";
contract SimpleDice is usingOraclize {
address owner;
mapping (bytes32 => address) bets;
function SimpleDice(){
owner = msg.sender;
}
function() payable {
if (msg.sender != owner) throw;
}
function __callback(bytes32 myid, string result) {
if (msg.sender != oraclize_cbAddress()) throw;
if (uint(bytes(result)[0]) - 48 > 3) {
if (bets[myid].send(2 wei)) {
log0("winner");
}
}
}
function bet() payable {
rollDice();
}
function rollDice() {
bytes32 myid = oraclize_query("WolframAlpha", "random number between 1 and 6");
bets[myid] = msg.sender;
}
function kill(){
if (msg.sender == owner) suicide(msg.sender);
}
}
This code compiles and deploys just fine. However notice the following issues:
1) The first time I call bet() it seems to work fine. HOWEVER as you may see, Oraclize never executed what it was supposed to and/or never called my __callback function
2) The subsequent times I call bet, the transaction fails with an "invalid jump destination"
3) The subsequent calls cost a lot of gas which is completely lost every time.
Does anyone have any idea what the heck is going on? thanks a lot!