1

why i can't initialise a variable

address payable public owner=msg.sender;

but i have to do this instead

address payable public owner;
constructor() payable 
{
    owner = payable(msg.sender);
}
  • Because msg.sender is not constant, and it will have a value during the contract deployment. – Ismael Apr 15 '22 at 18:52

0 Answers0