I'm trying to fetch the current ethereum to usd rate from following link: https://api.infura.io/v1/ticker/ethusd
This is my code snippet
pragma solidity ^0.4.11;
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";
contract ExampleContract is usingOraclize {
string public ETHUSD;
event LogConstructorInitiated(string nextStep);
event LogPriceUpdated(string price);
event LogNewOraclizeQuery(string description);
function ExampleContract() payable {
LogConstructorInitiated("Constructor was initiated. Call 'updatePrice()' to send the Oraclize Query.");
}
function __callback(bytes32 myid, string result) {
if (msg.sender != oraclize_cbAddress()) revert();
ETHUSD = result;
LogPriceUpdated(result);
}
function updatePrice() payable {
if (oraclize_getPrice("URL") > this.balance) {
LogNewOraclizeQuery("Oraclize query was NOT sent, please add some ETH to cover for the query fee");
} else {
LogNewOraclizeQuery("Oraclize query was sent, standing by for the answer..");
oraclize_query("URL", "json(https://api.infura.io/v1/ticker/ethusd).bid");
}
}
}
but when I press updatePrice(), the transaction goes successful but no value is captured in ETHUSD variable. Any idea, what I'm doing wrong? I tried using this url and it works fine (for EUR,GBP) "json(http://api.fixer.io/latest?symbols=USD,GBP).rates.GBP"