Earlier, we introduced two special system variables: block.timestamp and block.number. Solidity provides us with a set of global variables and special functions that exist in the global namespace and that are mainly used to provide information about blocks and transactions.
The following is a list from the official documentation:
- block.blockhash(uint blockNumber): Returns a hash of the given block (bytes32)—only works for the 256 most recent blocks, excluding the current block
- block.coinbase (address): Provides the current block miner's address
- block.difficulty (uint): Represents the current block difficulty
- block.gaslimit (uint): Represents the current block gas limit
- block.number (uint): Represents the current block number
- block.timestamp (uint): Represents the current block timestamp, as seconds since Unix epoch
- gasleft() (uint256): Returns the remaining gas
- msg.data (bytes): Represents a copy of calldata
- msg.sender (address): Represents the address of the sender of the message (current call)
- msg.sig (bytes4): Represents the first four bytes of calldata (that is, function identifier)
- msg.value (uint): Represents the number of wei sent with the message
- tx.gasprice (uint): Represents the gas price of the transaction
- tx.origin (address): Represents the sender of the transaction
The values of all attributes of the msg object, including msg.sender and msg.value, vary for every external function call according to the sender and the amount carried by the transaction. In our constructor, we can provide the auction owner as an argument, using msg.sender to directly set the sender of the deployment transaction as the owner: auction_owner = msg.sender;.