Doc: http://solidity.readthedocs.io/en/develop/index.html
Cheatsheet: https://github.com/manojpramesh/solidity-cheatsheet
Storage vs. Memory & Stack
- Storage
- state variables
- variable with "storage" modifier
- Memory
- variable with "memory" modifier
- function arguments, by default
- local variables of struct, array or mapping type storage by default
- Stack
- local variables by value (NEITHER array, nor struct nor mapping)
- bool (true false)
- integers
- int / uint = int256 / uint256
- intN / uintN : N in steps of 8, bits
- Mapping
- declaration: mapping(_KeyType => _ValueType)
- use
- work
- seen as a hash table
- virtually initialized such every possible key exists and value all zeros
- key not stored, only keccak256 hash of key is used to lookup value
- no key/value "set"
- possible marked as public
- has address, has no key
- "this" means current instance of the type derived from the Address (the contract type)
- explicitly converts to address
- deployed only once at a specific address
- though same source code can be deployed multiple times at different addresses, for no reason
- no instance, stateless
- code reused
- using EVM DELEGATECALL (CALLCODE until Homestead)
- or called directly if do not modify state (i.e. they are "view" or "pure" functions)
- L.f() - L name of library
- be seen as implicit base contracts of the contracts that use them
- internal functions of libraries visible to all contracts
- code executes in the calling contract's context
- "this" points to calling contract
- access to calling contract's storage
- when in same source code with some contract & deploy that contract, there will be two deployments - one for library one for contract