5

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!

3

Thomas from Oraclize here.

The issue was geth-related and being experienced on the Morden testnet only (events filters were all messed up - the exact issue in geth is still being investigated).

We have enabled parity-based events listeners on the testnet as well - all the pending queries have now been processed (including yours), my apologies for the delay.

  • It happens, thank you though! Good to know I'm not going entirely crazy yet ;-) – KennyV Oct 21 '16 at 9:15
  • Could this be happening right now with the Rinkeby network? I'm not getting a __callback trigger form my contract either : \ – okwme Oct 2 '17 at 21:14
1

Did you send enough Ether with your request? The costs do apply to Morden as well!

I had similar problems and had to send about 1 ETH with my request (at least it worked then, less might have been enough, but 1 ETH worked always). Of course, I only did this in Morden.

  • This may have changed since then, this should be handled automatically, if you check out the internal transactions you'll see the fee being sent. – KennyV Oct 20 '16 at 15:04
0

Make the constructor payable too. Refer the following code.

constructor() public payable{
        owner = msg.sender;
    }
-2

I am having the same problem, Was it solved?

https://ropsten.etherscan.io/tx/0x6646662f4432819e58179fd4d1433f4f0806e2da093c49758a81441ad6ba12fe

contract ProofOfExistence4 is usingOraclize {

string public currentRound;
bytes32 public id;

function ProofOfExistence4 () {
  //id = 1;
}
function() payable {}

event ResultUpdated (string currentRound);

function __callback(bytes32 myid, string result, bytes proof)  {
    currentRound = "0";
    if (msg.sender != oraclize_cbAddress()) throw;

    currentRound = "1";
    currentRound = result;
    ResultUpdated(currentRound);
}

function __callback(bytes32 myid, string result)  {
    currentRound = "2";
    if (msg.sender != oraclize_cbAddress()) throw;

    currentRound = "3";

    currentRound = result;
    ResultUpdated(currentRound);
}

function getNumber() public payable {
    id = 3;
    oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);
    id = oraclize_query("WolframAlpha", "random number between 0 and 100");
    //currentRound = id;
    }
}

Thanks,

  • Is this an answer or a question? – Waqar Lim May 6 '17 at 21:30
  • Was a question, oraclize had a issue and solved this last monday on ropsten network. They answered me on gitter. – Livio May 10 '17 at 3:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.