Solidity Output Prediction Hard +35 XP
msg.sender in Constructor
Who is msg.sender when a contract is deployed?
SolidityRead-only
contract MyToken {
address public owner;
constructor() { owner = msg.sender; }
}What is the output?
Show answer and explanation
Answer: The deploying account/contract
During construction, msg.sender is the address that deployed the contract. This is commonly used to set the contract owner.
Hint: Who triggered the deployment transaction?
What this challenge tests
Output Prediction in Solidity: constructor, msg.sender.