Re: Calculating costs of non trivial functions
The execution cost is the important one, but to calculate teh entire transaction cost given the execution cost should not be so difficult...
Re: Calculating costs of non trivial functions
When you say "estimate/calculate" the gas cost, how should it be done? "By hand" using the gas costs (per opcode) written in the Yellow Paper? Or it suffices to test the contract on the Remix VM and check transaction/execution cost there?
Re: Calculating costs of non trivial functions
In theory by hand and NOT trough simuations in Remix (actual cost can be parameter dependent and so inaccurate). But you can trick Remix to evaluate it for you by decomposing infinite cost functions and composing the estimated cost back togheter properly. THEN you can use simulation to prove your estimations are right.
Re: Calculating costs of non trivial functions
Sorry, I don't understand. To make a concrete example, my giftContent function already requires less than infinite gas as per Remix's estimation (as seen in the attached screenshot). Can I provide directly this number?
Re: Calculating costs of non trivial functions
Where have you taken the screenshot execution cost from exactly? In the 'gasEstimates' tab of 'compile'->'details' you can find the gas calculation (when possible) for your functions. And yes you can use remix gas estimations as good. The non trivial part is to evaluate gas of whar looks like infinite gas according to remix (e.g. parameters dependent functions).
Re: Calculating costs of non trivial functions
Re: Calculating costs of non trivial functions
Ok, as long as it is the same (i.e. it is not the cost of a transaction containing that function call, that can be influenced by external factors, as the parameters passed).