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

Provide a constant method to getPrice() to know how much Oraclize is going to charge #35

Open
jchittoda opened this issue Jan 27, 2018 · 6 comments

Comments

@jchittoda
Copy link

I want to know how much is the fee oraclize is going to charge me before I send a transaction or Oraclize API.
For example I want to know How much Oraclize would charge me for "URL" with specific gasLimit and gasPrice.

getPrice("URL", gasLimit, gasPrice) public constant

If I know this before making the actual request on platform. I can send that specific ETH into my transaction. Also we can charge that much of ETH from our customers.

@D-Nice
Copy link
Contributor

D-Nice commented Jan 31, 2018

Thanks for the suggestion @jchittoda

In regards to it, we don't think it's something critical (as you should already be able to do what you need with the implementation as-is), unless you can prove otherwise, so for now, will add this as a todo for a future update.

In regards to getting the price, you can do this already without sending any transaction on-chain, by explicitly using call, which should emulate what you're looking for with the constant specifier addition. Consider using the following call method in web3 over sendTransaction for this purpose: https://github.com/ethereum/wiki/wiki/JavaScript-API#web3ethcall

You will need to setup a helper from within your own contract, that calls getPrice, and then you call that helper using the above method. You may even be able to set the helper itself constant, getting the effect you want, without requiring an update from us.

@jchittoda
Copy link
Author

     function getOraclizePrice() public constant returns (uint) {
          return oraclize_getPrice("URL", 80000);
     }

We have already been doing this. But during the solidity compilation it give below warning.

Warning: Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.

The reason why we want this functionality is because at our platform user pay for the USD rate update in our Dapp, for this to happen, we need to fill in the MetaMask with the exact cost that Oraclize will charge our user for this call.
Please get this method added, so that it stops giving compilation errors with 0.4.18 versions.

@D-Nice
Copy link
Contributor

D-Nice commented Feb 1, 2018

We agree this is a change we'll add in in a coming update, it's really not more than an annoyance at this point, in that you get that warning message from the compiler. The functionality is still the same.

@chris-chr
Copy link

I have the same issue with @jchittoda (the only difference is that I am using view instead of constant) but in compiler version 0.5.4 is a TypeError and I can't compile my contract.

TypeError: Function declared as view, but this expression (potentially) modifies the state and thus requires non-payable (the default) or payable.

Could you suggest any workaround until a fix is implemented?

@D-Nice
Copy link
Contributor

D-Nice commented Feb 25, 2019

We have a new connector we'll be deploying very soon, that has the view specifier applied to it.

Once we have it deployed, we'll in tandem update the oraclizeAPI interface.

You can already update that part of the oraclizeAPI @chris-chr to overcome the compilation error you've encountered.

Change

https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.5.sol#L42

to

function getPrice(string memory _datasource, uint _gasLimit) public view returns (uint _dsprice);

by adding the view specifier to that interface definition. That is the change we'll be doing ourselves to the api upon deployment.

@Duncan-Brain
Copy link

Duncan-Brain commented Mar 3, 2019

Hi,

I also would be interested in something to easily get the price of a datasource. I am not interested in a function though. Just a public variable on a library, or something I could call, would do for me.
uint public randomPrice; uint public URLPrice; //et cetera...
I can do my own math on gas limit and gas price .

Thanks for all the work you are doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants