Hello Devs
I tried to change the version of my contract from 0.6.12 to 0.8.0 and I got the error below on the part I show you, please let me know what is happened and how to fix it?
Thanks
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this;
return msg.data;
}
}
This is the error:
TypeError: Return argument type address is not implicitly convertible to expected type (type of first return variable) address payable.
Skyge
March 31, 2022, 1:09am
2
1 Like
You got the error cause you got a helper library like the openZeppelin contract library with a different solidity version
1 Like
Hey @shawn_t
as @Skyge suggested you should use the latest version of Context.sol
Btw an easy fix is to cast the msg.sender to payable in this way:
function _msgSender() internal view virtual returns (address payable) {
return payable(msg.sender);
}
1 Like
Thank you, I just correct the code the way you suggest now it is working, appreciate it
1 Like
Btw, can you tell me how to use the latest version of Context.sol? should I just import it?
You can simply remove the payable for _msgSender function from address payable to address
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
//this;
return msg.data;
}
}
1 Like