Skill 2.1.5
Use constructors, constants, immutables and global variables
Key Concepts
The constructor runs once, during deployment, and its code is not part of the deployed runtime bytecode. It typically records the owner and initial parameters. constant variables must be assigned a compile-time value; immutable variables are assigned once in the constructor. Both are embedded in the bytecode and use no storage slot, so reading them is cheap.
Global variables expose context. msg.sender is the immediate caller, msg.value the wei sent with the call and msg.data the calldata. block.timestamp, block.number, block.chainid, block.basefee and block.prevrandao describe the block. tx.origin is the externally owned account that started the transaction, and gasleft() returns the remaining gas. address(this).balance is the contract's ether balance.