0

below is my contract with compiler version >=0.6.0.

when I change the compiler version ^0.8.2 I am getting error as:

Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable.

pragma solidity >=0.6.0;


abstract contract Context {
    function _msgSender() internal view virtual returns (address payable) {
        return   msg.sender;
    }
    

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

can anyone help me to sort out this issue?

0

Solidity v0.8.0 includes a breaking change which requires address to be explicitly converted to the address payable type.

Wrapping the returned msg.sender would solve the problem:

function _msgSender() internal view virtual returns (address payable) {
    return payable(msg.sender); // explicit conversion
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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