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;

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"

  • I don't know anything about Oraclize, but what does your log say? One of the two events will have emitted. May 24, 2018 at 5:37
  • Wild guess, but maybe the TLS ("https") is causing problems.
    – Maurycy
    May 25, 2018 at 7:17
  • @Maurycy, I tried with http but still no luck May 25, 2018 at 18:40

1 Answer 1


I have just tried your code, and it works just fine. Do you mind sharing what network you are trying this on and how? In the example below, I'm using Oraclize's fork of remix, with an integrated Oraclize module, allowing you to use Oraclize right in the browser vm.


Ensure the network you are using is either mainnet or a public testnet. If it's not either of those, than the appropriate Oraclize architecture needs to be deployed on it, which can be done using ethereum-bridge npm package.

enter image description here

  • 1
    I tried it on the fork of remix u provided and its working perfectly on both VM and ropsten. Then I switched back to simple remix version, and what I observed is that, it still didn't give response because of import statement, I then copy and pasted all of the oracalizeAPI code and it worked fine. Thanks for giving us the path. Here is verified code link: ropsten.etherscan.io/address/… May 30, 2018 at 7:18

Your Answer

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

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