This contract is hosted at https://github.com/provable-things/ethereum-examples/blob/master/solidity/truffle-examples/kraken-price-ticker/contracts/KrakenPriceTicker.sol
I have made the constructor payable and transferring ether while deploying, The original contract was calling update method recursively from __callback but I have removed it.
pragma solidity >= 0.5.0 < 0.6.0;
//import "github.com/provable-things/ethereum-api/provableAPI.sol";
import "https://github.com/provable-things/ethereum-api/provableAPI_0.5.sol";
contract KrakenPriceTicker is usingProvable {
string public priceETHXBT;
event LogNewProvableQuery(string description);
event LogNewKrakenPriceTicker(string price);
constructor()
public
payable
{
provable_setProof(proofType_Android | proofStorage_IPFS);
update(); // Update price on contract creation...
}
function __callback(
bytes32 _myid,
string memory _result,
bytes memory _proof
)
public
{
require(msg.sender == provable_cbAddress());
// update(); // Recursively update the price stored in the contract...
priceETHXBT = _result;
emit LogNewKrakenPriceTicker(priceETHXBT);
}
function update()
public
payable
{
if (provable_getPrice("URL") > address(this).balance) {
emit LogNewProvableQuery("Provable query was NOT sent, please add some ETH to cover for the query fee!");
} else {
emit LogNewProvableQuery("Provable query was sent, standing by for the answer...");
provable_query(60, "URL", "json(https://api.kraken.com/0/public/Ticker?pair=ETHXBT).result.XETHXXBT.c.0");
}
}
}
I cant even deploy this contract, Error I am getting is
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