Disclosure: am an Oraclize employee.
There includes in the Oraclize API a helper function called oraclize_getPrice
. It expects two parameters, the first is the data-source you are querying, for example "URL" or "computation", and the second is the gas limit you are providing to Oraclize to run your __callback
. It returns the amount of Wei as a type 'uint' that your query will cost, and so take out of your contract when you call oraclize_query
.
It's calculated by taking your gas limit supplied (in your case 800000) and multiplying it by the gas price you may or may not have specified. If you haven't set a custom limit via oraclize_setCustomGasPrice
then it will default to 20gwei
. It will then add to this the base price of the query type you are making, in this case "URL", plus any additional fee for a proof type (You can see the breakdown here). Fees are calculated in Wei using the current USD/ETH exchange rate.
Calculating just the gas cost of your fee (as you did in your reply):
800000 gasLimit * 20e8 gasPrice = 0.016 ETH
Which at the current ETH prices you can see is by far the larger part of the $5 (~ 90%) fee you're seeing leave you contract. And as such, it's imperative you make your __callback
(and indeed any function in Solidity) as gas efficient as possible!
W/r/t pivoting away from Oraclize, that is of course your prerogative. You still ought to fine-tune the gas prices of your contract functions, since those will need to be paid regardless by either yourself or users of your smart-contract.
But what Oraclize offer as a service is a trustless model where, via the proof-types supplied, you don't have to trust Oraclize at all. Better still, you can put a value on that trustlessness. By choosing say the TLS_Notary proof, you're relying on an AWS instance, the cost of hacking/breaking/altering then is quantifiable. This means you know for how much your Oraclize-dependant contract is "safe", incentivally speaking.
You can absolutely roll your own of course, but should you start requiring this level of quantifiable trustlessness and thus start implementing the structures required to achieve this, you may soon start to appreciate that $0.05c fee after all!