I'm currently learning solidity programming to create a basic smart contract based on a 2018 tutorial where solidity was using version 4. I'm currently using truffle v5.0.21. I understand that there was an update from "address" to "address payable", but i'm still not able to get it to work after referencing to similar threads. Appreciate any help. Thanks!
Code for ApprovalContract.sol:
pragma solidity >=0.4.18;
contract ApprovalContract {
address public sender;
address public receiver;
address public constant approver = 0xAFXXX;
function deposit(address _receiver) external payable{
require(msg.value > 0);
sender = msg.sender;
receiver = _receiver;
}
function viewApprover() external pure returns(address) {
return(approver);
}
function approve() external{
require(msg.sender == approver);
receiver.transfer(address(this).balance);
}
}
Error that comes out on CMD:
//start of error code
TypeError: "send" and "transfer" are only available for objects of type "address payable", not "address". receiver.transfer(address(this).balance); ^---------------^
Compilation failed. See above.
//end of error code