Answer the question
In order to leave comments, you need to log in
TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address".?
pragma solidity >=0.7.0 <0.9.0;
contract Shop {
function pay (uint amount) public {
msg.sender.transfer(amount);
}
receive() external payable{}
}
Answer the question
In order to leave comments, you need to log in
Starting from version 0.8.x, transferring funds (send and transfer) requires the type to be `address payable`, with `msg.sender` becoming just `address` ( documentation link ). Those. you need to cast it to the `address payable` type and the code should work:
payable(msg.sender).transfer(amount);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question