The example code: [How does the constant keyword ACTUALLY work?](obsidian://open?vault=Vaultage&file=01%20-%20Resources%2FWeb3%2FMy%20Articles%2FHow%20does%20the%20constant%20keyword%20ACTUALLY%20work%3F) ### What is the Selector 0x471f7cdf? In Ethereum smart contracts, a **function selector** is the first 4 bytes of the Keccak-256 hash of a function’s signature. It’s how the EVM identifies which function to execute when a transaction calls a contract. The signature is the function name plus its parameter types (no spaces), like myFunction(uint256,address). In our bytecode, both versions (```NoConstant.sol``` and ```Constant.sol```) include this sequence in the runtime code: ``` 0x003b: PUSH4 0x471F7CDF // Push the selector onto the stack 0x0040: EQ // Check if it matches the calldata’s first 4 bytes 0x0041: PUSH1 0x2A // If equal, jump to the getter function 0x0043: JUMPI // Perform the jump if true ``` This ```0x471f7cdf``` is the selector for the automatically generated getter function for **favoriteNumber**. #### Reverse-Engineering the Selector To figure out what function this corresponds to, we need to consider what Solidity does with a public variable. When you declare: ``` uint256 public favoriteNumber = 5; // or uint256 public constant favoriteNumber = 5; ``` Solidity creates a public getter function named favoriteNumber() that returns a uint256. The function signature is: ``` favoriteNumber() ``` Now, let’s compute the selector: 1. Take the string "favoriteNumber()". 2. Compute its Keccak-256 hash. 3. Extract the first 4 bytes. You can verify this with a tool like ethers.js: ``` const ethers = require("ethers"); console.log(ethers.keccak256(ethers.toUtf8Bytes("favoriteNumber()")).slice(0, 10)); // Outputs: 0x471f7cdf ```