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 when blockNumber is one of the 256 most recent blocks; otherwise returns zero
  • blobhash(uint index) returns (bytes32): versioned hash of the index-th blob associated with the current transaction. A versioned hash consists of a single byte representing the version (currently 0x01), 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 id
  • block.coinbase (address payable): current block miner’s address
  • block.difficulty (uint): current block difficulty (EVM < Paris). For other EVM versions it behaves as a deprecated alias for block.prevrandao (EIP-4399)
  • block.gaslimit (uint): current block gaslimit
  • block.number (uint): current block number
  • block.prevrandao (uint): random number provided by the beacon chain (EVM >= Paris)
  • block.timestamp (uint): current block timestamp as seconds since unix epoch
  • gasleft() returns (uint256): remaining gas
  • msg.data (bytes calldata): complete calldata
  • msg.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 message
  • tx.gasprice (uint): gas price of the transaction
  • tx.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 time
  • immutable: Can only be modified in the constructor function. Then they become a constant
  • storage: Persistent data stored on the blockchain
  • memory: Local variable scoped to the function that it is in

Function Modifiers:

  • public: anyone can call this function
  • private: Only this contract can call this function
  • returns: specifies the return value of a function
  • view: makes it readonly so nothing can modify in this function
  • pure: Does not read or write any data to the chain
  • internal: Private but accessible through inheritance
  • external: Can only be called by an outside application
  • payable: Allows ETH to be sent to a function. The amount is checked with the msg.value variable
  • nonpayable: 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.