storage , where all the contract state variables reside. Every contract has its own storage and it is persistent between function calls and quite expensive to use.html
memory , this is used to hold temporary values. It is erased between (external) function calls and is cheaper to use.git
stack , which is used to hold small local variables. It is almost free to use, but can only hold a limited amount of values.github
There are defaults for the storage location depending on which type of variable it concerns:app
state variables are always in storage
function arguments are in memory by default
local variables of struct, array or mapping type reference storage by default
local variables of value type (i.e. neither array, nor struct nor mapping) are stored in the stackless
function returnTrue() public pure returns(bool response) { return true; }
refide
簡化:
require() and revert() will cause refund the remaining gas
assert() will used up all the remaining gasui
Use require() to:this
use assert() to :.net
revert() it was said that revert can handle more complex logic.(emit that, I think we should use require() instead)
throw : deprecated調試
todo:
lib
use external source(local sol or git)
call from another contract
msg.sender what's in msg
ide 調試
string compare
return struct
testing
more useful ref:
best practise
Error: VM Exception while processing transaction: invalid opcode
-- out of index
Error: Invalid number of arguments to Solidity function
-- 參數不對