0

I implemented a contract to call a api via provable and ethereum-bridge on a private ethereum. In the first time, when calling a api, it works fine. However, when tring to call api again, I got an error. I needed to deploy a new contract, then it would work only first time.

Constructor

constructor () payable public {
        OAR = OracleAddrResolverI(0xC7E23C5c09AD7B55d25Ca7086AA45FCa462ce171);

    }

Calling api

function updatePrice() payable public {
        provable_query("URL", "json(https://api.pro.coinbase.com/products/ETH-USD/ticker).price");
   }

Provable code

function provable_query(string memory _datasource, string memory _arg) provableAPI internal returns (bytes32 _id) {
        uint price = provable.getPrice(_datasource);
        if (price > 1 ether + tx.gasprice * 200000) {
            return 0; // Unexpectedly high price
        }
        return provable.query.value(price)(0, _datasource, _arg);
    }

Error

errors.js:63 Uncaught (in promise) Error: Transaction has been reverted by the EVM:
{
  "blockHash": "0xdb7c30bd168f828a7d580381653f022eafaec91b6a074655a830e938bb3b3d03",
  "blockNumber": 7240,
  "contractAddress": null,
  "cumulativeGasUsed": 47064,
  "from": "0x3f4d231c61f6fbd5706920b8e3aa8ba49d42e716",
  "gasUsed": 47064,
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "status": false,
  "to": "0x7d381f40b1ab31691dfa1d80bee784f9cc896c7e",
  "transactionHash": "0x2a4d5692980a88bf65c448b2b627f018f9e916835d34b89a8e2290941b1fd2d6",
  "transactionIndex": 0,
  "events": {}
}
    at Object.TransactionError (errors.js:63)
    at Object.TransactionRevertedWithoutReasonError (errors.js:75)
    at index.js:447
  • when trying to call api again - How exactly are you trying? Please show your code. – goodvibration Feb 11 '20 at 6:55
  • @goodvibration I updated the api-calling code. In the first time I also used the same code. – Pakorn K Feb 11 '20 at 7:34
  • What is the code of function provable_query? – goodvibration Feb 11 '20 at 7:37
  • This function is inherited from provableAPI_0.5.sol. – Pakorn K Feb 11 '20 at 7:42
  • What is the code of provableAPI_0.5.sol? – goodvibration Feb 11 '20 at 7:50

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.