2
pragma solidity ^0.8.4;

contract Contract {
    address payable public owner;

    constructor() public {
     owner=payable(msg.sender);

    }
    
}

msg.sender is of type address by default?

so I need to explicitly cast it to address payable should I want it to receive funds?

1 Answer 1

6

Yes, this is the case since solidity v0.8.0

The global variables tx.origin and msg.sender have the type address instead of address payable. One can convert them into address payable by using an explicit conversion, i.e., payable(tx.origin) or payable(msg.sender).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.