使用可证明的 oracle 服务的 Solidity 合约不起作用或更新回调

问题描述

我正在尝试从可证明中调用 oracle 服务以获取当前以太币价值的美元价格。

我遵循了 Provable 教程和代码,但我的回调函数没有使用可证明的 URL 数据服务触发。我已经等了 15 多分钟,但我的变量 ETHUSD 仍然没有更新或回调函数被触发。

pragma solidity ^0.4.22;
import "github.com/provable-things/ethereum-api/provableAPI_0.4.25.sol";

contract ExampleContract is usingProvable {

   string public ETHUSD;
   event LogConstructorInitiated(string nextStep);
   event LogPriceUpdated(string price);
   event LogNewProvableQuery(string description);

   function ExampleContract() payable {
       LogConstructorInitiated("Constructor was initiated. Call 'updatePrice()' to send the Provable Query.");
   }

   function __callback(bytes32 myid,string result) {
       if (msg.sender != provable_cbAddress()) revert();
       ETHUSD = result;
       LogPriceUpdated(result);
   }

   function updatePrice() payable {
       if (provable_getPrice("URL") > this.balance) {
           LogNewProvableQuery("Provable query was NOT sent,please add some ETH to cover for the query fee");
       } else {
           LogNewProvableQuery("Provable query was sent,standing by for the answer..");
           provable_query("URL","json(https://api.pro.coinbase.com/products/ETH-USD/ticker).price");
       }
   }
}

如何使用 provable_query 获取 ETHUSD 值?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)