Link to this headingContracts
All functions are public so auth checks are needed in each function if necessary.
Link to this headingVariables
Special Variables:
blockhash(uint blockNumber)returns (bytes32): hash of the given block whenblockNumberis one of the 256 most recent blocks; otherwise returns zeroblobhash(uint index)returns (bytes32): versioned hash of theindex-th blob associated with the current transaction. A versioned hash consists of a single byte representing the version (currently0x01), followed by the last 31 bytes of the SHA256 hash of the KZG commitment (EIP-4844). Returns zero if no blob with the given index exists.block.basefee(uint): current block’s base fee (EIP-3198 and EIP-1559)block.blobbasefee(uint): current block’s blob base fee (EIP-7516 and EIP-4844)block.chainid(uint): current chain idblock.coinbase(address payable): current block miner’s addressblock.difficulty(uint): current block difficulty (EVM < Paris). For other EVM versions it behaves as a deprecated alias forblock.prevrandao(EIP-4399)block.gaslimit(uint): current block gaslimitblock.number(uint): current block numberblock.prevrandao(uint): random number provided by the beacon chain (EVM >= Paris)block.timestamp(uint): current block timestamp as seconds since unix epochgasleft()returns (uint256): remaining gasmsg.data(bytes calldata): complete calldatamsg.sender(address): the immediate parent of the current caller. If call chain A->B->C->D then msg.sender is C.msg.sig(bytes4): first four bytes of the calldata (i.e. function identifier)msg.value(uint): number of wei sent with the messagetx.gasprice(uint): gas price of the transactiontx.origin(address): The earliest person who started the contract function. If call chain A->B->C->D then tx.origin is A.
Link to this headingModifiers
Variable Modifiers:
constant: Hard coded at compile timeimmutable: Can only be modified in theconstructorfunction. Then they become a constantstorage: Persistent data stored on the blockchainmemory: Local variable scoped to the function that it is in
Function Modifiers:
public: anyone can call this functionprivate: Only this contract can call this functionreturns: specifies the return value of a functionview: makes it readonly so nothing can modify in this functionpure: Does not read or write any data to the chaininternal: Private but accessible through inheritanceexternal: Can only be called by an outside applicationpayable: Allows ETH to be sent to a function. The amount is checked with themsg.valuevariablenonpayable: Restricts payment to a function; this is the default behavior
Class Modifiers:
Ownable: OpenZeppelin code to make a contract that can restrict functions to only be called by the owner/deployer
Link to this headingFunctions
fallback: Called when a function does not exist on the contract or when ETH is sent with non-empty msg.data
selfdestruct(recipientAddress): Will now only destroy a contract when it’s called in the same transaction that created the contract. Otherwise it transfers the ETH in the contract to the recipientAddress; all other tokens are lost.
Link to this headingProxy Contracts
Uses delegatecall to call another contract that contains the code. As a delegate call
Link to this headingPause-able Contracts
openzeppelin Pausable Contract Implementation
Usualy an admin is able to pause/unpause a contract to limit functionality until it is unpaused. This is usually done in emergencies or if there is a known bug.