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


1 Answer 1


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 and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.