I am using testrpc as client and truffle as development framework.And also using ethereum-bridge for Oraclize.

This is the contract code.I have downloaded the 'Oraclize API' (oraclizeAPI_0.4.sol)from the Oraclize github repo.I have added this file to the truffle contracts folder, and rename the file to usingOraclize.sol.And it is imported in the given contract.

  pragma solidity ^0.4.0;

  import "./usingOraclize.sol";

  contract ApiCall is usingOraclize {

        uint public DieselPriceUSD;

        function ApiCall() {

                OAR = OraclizeAddrResolverI(0x9851eb2d10b765d8857e7e1b060bc1eb166e89f2);

        function __callback(bytes32 myid, string result) {
                if (msg.sender != oraclize_cbAddress()) throw;
                DieselPriceUSD = parseInt(result, 2); 

        function update() payable {
                oraclize_query("URL", "xml(https://www.fueleconomy.gov/ws/rest/fuelprices).fuelPrices.diesel");


The XML file in the link 'https://www.fueleconomy.gov/ws/rest/fuelprices' is as follows.


I have compiled the contract using 'truffle' enter image description here The Oraclize return the result diesel price as '2.57' using ethereum-bridge.

enter image description here

I want to use the result in index.js file to display it in frontend.How to use the result in dapp frontend?

1 Answer 1


When you get the result in your contract, log it as an event. Using web3.js or ethjs, make JavaScript code to listen for that event (see the docs for watch or filter), and display it on your HTML page.


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.