Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What the actual price for the URL request? #38

Closed
akucheruk-vareger opened this issue Feb 13, 2018 · 2 comments
Closed

What the actual price for the URL request? #38

akucheruk-vareger opened this issue Feb 13, 2018 · 2 comments
Labels

Comments

@akucheruk-vareger
Copy link

akucheruk-vareger commented Feb 13, 2018

Hi,

From the manual we can learn that the base price for the URL request is 0.01$
But I've got 0.0040336 Ether (for this days) for this contact code:

  function getTokens(address beneficiary) public payable {
        require(beneficiary != address(0));
        uint256 price =  oraclize_getPrice("URL");
        if (price > msg.value) {
            LogNewOraclizeQuery("Oraclize query was NOT sent");
        } else {
            LogNewOraclizeQuery("Oraclize query was sent, standing by for the answer..");
            // TODO creating query with address parameter
            bytes32 queryId =
                oraclize_query("URL", "xml(https://example.com/balances).tokenBalance");
            tokenHolders[queryId] = beneficiary;
        }
    }

    function __callback(bytes32 myid, string result) public{
        require(msg.sender == oraclize_cbAddress());

        uint tokenBalance = parseInt(result, 2);
        address beneficiary = tokenHolders[myid];

        token.mint(beneficiary, tokenBalance);
    }

https://ropsten.etherscan.io/tx/0x8c2168ce411f175b999ec362f8f9ac06a42b84175a46dc796448dfa3c6833a55

0.0040336 Ether - 0.004 (200 000 gas limit * 20Gwei) = 0.0000366 Ether = 0.03$

So, what the actual price for the URL request and how to know it?

Thank you.

@bertani
Copy link
Contributor

bertani commented Feb 13, 2018

The ETHUSD price is not updated that often on testnets, so it might be a bit off, on mainnet we try to keep it updated to reflect the market changes. If you want to check in advance the price, you can use the oraclize_getPrice(datasource, callbackgas) helper method. I hope this helps!

@akucheruk-vareger
Copy link
Author

Got it.
Thank you!

@bertani bertani closed this as completed Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants