8

Why this code works one time? First time I get proper random number, but after that I get wallet response "Data can't be executed, so it will use all provided gas"

I'm in Testnet.

contract Random_number is usingOraclize {
  string public randomNumber;

  function Create_random_number() {
    oraclize_setNetwork(networkID_testnet);
    oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);
    oraclize_query("WolframAlpha", "random number between 0 and 100");
  }

  function __callback(bytes32 myid, string result, bytes proof) {
    if (msg.sender != oraclize_cbAddress()) throw;
    randomNumber = result;
  }
}
  • The constructor function does not have the same name as the contract which is required. – JohnAllen Jul 19 '17 at 15:58
14

Thomas from Oraclize here.

You probably are having this issue because you are not sending any value along. The Oraclize API calls come at a cost, the small fee we charge is paid in advance when calling oraclize_query. The first API call from each contract is free, so this is why your first call is working. Please check out our pricing here.

This applies to the testnet as well - of course testnet coins have no value, but we charge them anyway so that you can test the same pricing logic you have on the mainnet.

For any further Oraclize specific question you can join our gitter channel to get a more interactive support from us.

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.