Timeline for Why does a contract method that only returns a value doesn't use a constant and cost gas?
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 14, 2017 at 15:23 | comment | added | Guenole de Cadoudal | Hi @MikkoOhtamaa have you been able to test ? | |
Mar 12, 2017 at 23:21 | comment | added | Guenole de Cadoudal | Hi, please try having both a constant and non constant function on a contract, modifying a state variable of a simple contract and test it. You will see how it behaves. Good luck | |
Mar 12, 2017 at 23:18 | comment | added | Mikko Ohtamaa | @GuenoledeCadoudal I am pretty sure you are wrong - currently constant keyword does nothing: Please see the notes here solidity.readthedocs.io/en/develop/… | |
Mar 12, 2017 at 13:09 | comment | added | Guenole de Cadoudal | The constant keyword is indeed optional. But it does not mean that the compiler will determine for you if states are changed by the function. In reality, it is simple: the developper uses constant, then the execution on the function is done on the local evm with the local data of the blockchain (up to date or not) and returned value is available locally. If the developer did not use the keyword then the function is treated as a transaction and is required to be mined. Return value is not available to the caller (unless using the debug.traceTransaction!) | |
Mar 11, 2017 at 21:12 | comment | added | migu |
I've added logs and another method with a constant to better illustrate my point.
|
|
Mar 11, 2017 at 20:42 | history | answered | Mikko Ohtamaa | CC BY-SA 3.0 |