provable-things / ethereum-api

Provable API for Ethereum smart contracts

Home Page:https://docs.provable.xyz/#ethereum

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

transact to DieselPrice.update errored: VM error: revert.

xyzbilal opened this issue · comments

hi, I m trying to run example project on remix and I m getting this error. I couldnt find solution for that. any idea how to solve it?

https://remix.ethereum.org/#optimize=false&runs=200&evmVersion=null&version=soljson-v0.8.17+commit.8df45f5f.js

code is

pragma solidity ^0.8.17;

import "https://github.com/provable-things/ethereum-api/blob/master/contracts/solc-v0.8.x/provableAPI.sol";

contract DieselPrice is usingProvable {

    uint public dieselPriceUSD;

    event LogNewDieselPrice(string price);
    event LogNewProvableQuery(string description);

    constructor() payable{
      update();
    }

    function __callback(
        bytes32 _myid,
        string memory _result
    )
        public
    {
        require(msg.sender == provable_cbAddress());
        emit LogNewDieselPrice(_result);
        dieselPriceUSD = parseInt(_result, 2); // Let's save it as cents...
        // Now do something with the USD Diesel price...
    }

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

when I try to deploy it gives error below

[vm]from: 0x5B3...eddC4to: DieselPrice.(constructor)value: 0 weidata: 0x608...3656clogs: 0hash: 0xed5...e5fbb
creation of DieselPrice errored: VM error: revert.

revert
	The transaction has been reverted to the initial state.
Note: The called function should be payable if you send value and the value you send should be less than your current balance.
Debug the transaction to get more information.

Thanks