My contract is to generate rand number with oraclize. The code as follows:
_`pragma solidity ^0.4.11;
import "../node_modules/ethereum-api/oraclizeAPI.sol";
string public temperature = "hello,world";
uint256 public randNumber = 0;
function Orac() {
OAR = OraclizeAddrResolverI(0x6f485c8bf6fc43ea212e93bbf8ce046c7f1cb475);
oraclize_setProof(proofType_Ledger);
update();
}
function __callback(bytes32 _queryId, string _result, bytes _proof) {
if (msg.sender != oraclize_cbAddress()){
throw;
}
//temperature = result;
// do something with the temperature measure..
// 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..
// // for simplicity of use, let's also convert the random bytes to uint if we need
// uint maxRange = 2**(8* 7); // 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
// randNumber = uint(sha3(_result)) % maxRange; // this is an efficient way to get the uint out in the [0, maxRange] range
// update();
// }
}
function update() payable {
//oraclize_query("WolframAlpha", "temperature in London");
//oraclize_query(60, 'URL', 'html(https://www.youtube.com/watch?v=9bZkp7q19f0).xpath(//*[contains(@class, "watch-view-count")]/text())');
//oraclize_query("URL", "json(http://api.fixer.io/latest?symbols=USD,GBP).rates.GBP");
uint N = 7; // 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 = 20000000; // amount of gas we want Oraclize to set for the callback function
bytes32 queryId = oraclize_newRandomDSQuery(delay, N, callbackGas);
}
function multi (uint256 x,uint256 y) public view returns(uint256) {
return x*y;
}
function getTemp () public view returns(string) {
return temperature;
}
But if i delete the line "bytes32 queryId = oraclize_newRandomDSQuery(delay, N, callbackGas);" in function update(),I could deploy the contract success.I know there is something wrong with the line.Someone can help me?Thanks!