0

I have been running this code in remix but getting error.

pragma solidity ^0.5.8;

// import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";

contract DieselPrice is usingOraclize {

    uint public dieselPriceUSD;
    string public re;

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

    constructor() public {
        update(); // First check at contract creation...
    }

    function __callback(bytes32 myid, string memory result) public {
        // require(msg.sender == oraclize_cbAddress(),"cda");
        emit LogNewDieselPrice(result);
        re = result;
        // Log(result);
        // dieselPriceUSD = parseInt(result, 2); // Let's save it as cents...
        // Now do something with the USD Diesel price...
    }

    function update() public payable {
        emit LogNewOraclizeQuery("Oraclize query was sent, standing by for the answer...");
        oraclize_query("URL", "xml(http://rss.cnn.com/rss/cnn_topstories.rss).rss.channel.item.0.title","asd");
    }
}

In truffle the error was invalid opcode,

in remix it shows error: revert. revert The transaction has been reverted to the initial state. Note: The constructor should be payable if you send value.

Please help

  • what did you try in remix. What was the error you got? – Sanjay S B May 28 at 4:20
  • invalid opcode , – lokesh kumar May 28 at 4:47
  • what did you try to get that error? – Sanjay S B May 28 at 5:09
  • @SanjaySB i didn't get you, I just ran this code in remix.ethereum.org – lokesh kumar May 28 at 6:05
  • In Remix, first the code should be compilable before you can deploy it in the run tab. – Sanjay S B May 28 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.