Я использую Oraclize, чтобы получить случайное число, но N байтов смущает меня - PullRequest
0 голосов
/ 01 июня 2018

Кажется, что когда я даю запросу Oraclize N из 4, он всегда возвращает 19-значное число, это может быть совпадением, но я думаю, что нет.Что, если я на самом деле хочу число между, скажем, 0 и 10 * 10 ^ 18?

Возможно ли это?Вот как теперь выглядит мой Oraclize:

    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);

И в __callBack

        uint maxRange = totalEth -1; // deduct one so that when one gets added later it cant be bigger than the total eth.
        randomNumber = (uint(sha3(_result)) % maxRange) + 1 // this is an efficient way to get the uint out in the [1, maxRange] range
...