makoto / blockparty

NO BLOCK NO PARTY
MIT License
164 stars 41 forks source link

Use `constant` for non state changing functions #19

Closed makoto closed 7 years ago

makoto commented 8 years ago

Instead of

function get() returns(uint r) { return info; }

do

function get() constant returns(uint r) { return info; }

This way, the function does not incur transaction gas when called via RPC (or use internal keyword if intended to be used only internally).

http://solidity.readthedocs.io/en/latest/contracts.html?highlight=constant#constants

jefflau commented 7 years ago

Oh this is interesting. So that's how it knows it's not modifying state?

makoto commented 7 years ago

https://github.com/makoto/blockparty/pull/37