0

So I am using the following code

contract Damble is usingOraclize{

function Damble() {
    getRandomNumber();

}
    function __callback(bytes32 _queryId, string _result, bytes _proof) { 
    if (msg.sender != oraclize_cbAddress()) throw;

    if (oraclize_randomDS_proofVerify__returnCode(_queryId, _result, _proof) != 0) {
        // the proof verification has failed, do we need to take any action here? (depends on the use case)
    } else {
        // the proof verification has passed
        // now that we know that the random number was safely generated, let's use it..

        newRandomNumber_bytes(bytes(_result)); // this is the resulting random number (bytes)

        // for simplicity of use, let's also convert the random bytes to uint if we need
        uint maxRange = 10000000; // this is the highest uint we want to get. It should never be greater than 2^(8*N), where N is the number of random bytes we had asked the datasource to return
        uint randomNumber = uint(sha3(_result)) % maxRange; // this is an efficient way to get the uint out in the [0, maxRange] range

        newRandomNumber_uint(randomNumber); // this is the resulting random number (uint)
    }
}

function getRandomNumber() payable{ 
    oraclize_setProof(proofType_Ledger); // sets the Ledger authenticity proof
    uint N = 4; // number of random bytes we want the datasource to return
    uint delay = 0; // number of seconds to wait before the execution takes place
    uint callbackGas = 200000; // amount of gas we want Oraclize to set for the callback function
    bytes32 queryId = oraclize_newRandomDSQuery(delay, N, callbackGas);
}

The first time getRandomNumber() gets called from the constructor everything works fine. When I want to call getRandomNumber manually with a certain value (to pay for the Oraclize value) I need to put in more than $5 worth of eth that doesnt get spend otherwise the transaction fails but it dilutes my contracts ether balance. Other than that when i call getRandomNumber() after the constructor called from the constructor no events get fired even though a transaction comes in from the Oraclize address.

EDIT: this is a link to my contract: https://ropsten.etherscan.io/address/0x92f0dbf8b218e03f288da42c0f6d4df7de40c3f2

1

The problem seems to have solved itself, probably by having some balance within the contract itself.

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.