我想在 Remix 中使用 Oraclize 来测试它。我太愚蠢了,无法使用他们的例子。我怎样才能使这项工作?我从他们的Github获取了 YouTube-Views 代码并将其复制到 Remix
pragma solidity >= 0.5.0 < 0.6.0;
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";
contract YoutubeViews is usingOraclize {
string public viewsCount;
event LogYoutubeViewCount(string views);
event LogNewOraclizeQuery(string description);
constructor()
public
{
update(); // Update views on contract creation...
}
function __callback(
bytes32 _myid,
string memory _result
)
public
{
require(msg.sender == oraclize_cbAddress());
viewsCount = _result;
emit LogYoutubeViewCount(viewsCount);
// Do something with viewsCount, like tipping the author if viewsCount > X?
}
function update()
public
payable
{
emit LogNewOraclizeQuery("Oraclize query was sent, standing by for the answer...");
oraclize_query("URL", 'html(https://www.youtube.com/watch?v=9bZkp7q19f0).xpath(//*[contains(@class, "watch-view-count")]/text())');
}
}
当我使用 viewCount 它返回:
0:字符串:
这也发生在所有其他示例中。使用 WolframAlpha 例如。我还收到以下错误:
处理 WolframAlpha.update 错误:VM 错误:还原。revert 事务已恢复到初始状态。注意:如果您发送值,则应支付构造函数。调试事务以获取更多信息。