Global Variables
Block
block.coinbase: address - current block miner’s address
block.difficulty: uint - current block difficulty
block.gaslimit: uint - current block gaslimit
block.number: uint - current block number
block.timestamp: uint - current block timestamp
Msg
msg.data: bytes - complete calldata
msg.gas: uint - remaining gas
msg.sender: address - sender of the message(current call)
msg.value: uint - number of wei sent with the message
Now
- now: uint - current block timestamp(alias for block.timestamp)
Tx
tx.gasprice: uint - gas price of the transaction
tx.origin: address - sender of the transaction (full call chain)
Global Functions
assert(bool condition): abort execution and revert state changes if condition is
false
(use for internal error)require(bool condition): abort execution and revert state changes if condition is
false
(use for malformed input or error in external component)revert(): abort execution and revert state changes
block.blockhash(uint blockNumber) returns (bytes32): hash of the given block - only works for 256 most recent blocks
sha256(…) returns (bytes32): compute the SHA-256 hash of the (tightly packed) arguments
keccak256(…) returns (bytes32): compute the Ethereum-SHA-3(Keccak-256) hash of the (tightly packed) arguments
sha3(…) returns (bytes32): alias for keccak256
ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address): recover address associated with the public key from elliptic curve signature
addmod(uint x, uint y, uint k) returns (uint): compute
(x + y) % k
where the addition is performed with arbitrary precision and does not wrap around at 2 ** 256mulmod(uint x, uint y, uint k) returns (uint): compute
(x * y) % k
where the addition is performed with arbitrary precision and does not wrap around 2 ** 256selfdestruct(address recipient): destroy the current contract, sending its funds to the given address
suicide(address recipient): alias for selfdestruct
- .balance: uint256: balance of the Address in Wei
- .send(uint256 amount) returns (bool): send given amount of Wei to Address, returns `false` on failure
- .transfer(uint256 amount): send given amount of Wei to Address, throws on failure.
Scope Variables
this: current contract’s type - the current contract, explicitly convertable to address
super: the contract one level higher in the inheritance hierarchy
Function Visibility Specifier
public: visible externally and internally(creates accessor function for storage/state variables)
private: only visible in the current contract
external: only visible externally(only for functions) - i.e. can only be message-called)
internal: only visible internally
Modifiers
pure: for function - disallows modification or access of state - this is not enforced yet
view: for function - disallows modifiction of state - this is not enforced yet
payable: for function - allows them to receive Ether together with a call
constant: for state variable - disallow assignment(except initialization), does not occupy storage slot
contant: for function - same as view
anonymous: for events - does not store event signature as topic
indexed: for event parameters - store the parameter as topic