0

I am learning to use oracles in solidity and I have taken this code to see how it works. But I get the following error: "VM error: revert. revert The transaction has been reverted to the initial state. Note: The constructor should be payable if you send value. "

If someone knows how to help me I appreciate it, I've been trying for several days to make it work but I can not.

Thank you

The code:

pragma solidity ^0.4.24;
import "./oraclize.sol";

contract DieselPrice is usingOraclize {

uint public DieselPriceUSD;

event newOraclizeQuery(string description);
event newDieselPrice(string price);

function DieselPrice() public payable{
    update(); // first check at contract creation
}

function __callback(bytes32 myid, string result)public {
    if (msg.sender != oraclize_cbAddress()) throw;
    newDieselPrice(result);
    DieselPriceUSD = parseInt(result, 2); // let's save it as $ cents
    // do something with the USD Diesel price
}

function update() payable {
    newOraclizeQuery("Oraclize query was sent, standing by for the answer..");
    oraclize_query("URL", "xml(https://www.fueleconomy.gov/ws/rest/fuelprices).fuelPrices.diesel");
}

}

0

I've fixed it, the problem is that I was using the JavaScript VM and had to use web3

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.