0

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

1 Answer 1

1

I was able to deploy that contract. You cannot deploy it on a private/local chain, since the Provable service must be available in the chain. Fortunately the Provable service is available on all testnets. Further, you could implement a bridge to run it on a local chain, see https://docs.provable.xyz/#integrations-alternative-public-chains.

3
  • Still, it doesn't work, I deployed it on Rinkyby testnet but when I call priceETHXBT to check the updated price, It is still empty. Apr 10, 2020 at 9:27
  • Why do you think it doesn't work? It works for me: rinkeby.etherscan.io/tx/…. If you want to follow it on Etherscan, you just have to verify the contract and you will see shortly after the deployment the __callback function is called with the correct price value. Apr 10, 2020 at 20:41
  • I deployed it at 0xF36Ba1189519Ee2Dae3FeA65dc5025FD86A15877, But i couldnt check the updated price in my remix ide. Apr 11, 2020 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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