I'm taking the course from lynda.com "Ethereum: Building Blockchain Decentralized Apps (DApps)" but there's an issue with the contract we're given, and it won't compile:

pragma solidity ^0.5.0;

contract ApprovalContract {
    address payable public sender;
    address payable public receiver;
    address public constant approver = 0x3999BA5D247c800E5Ef3d4de66618741E3675379 ;

function deposit(address _receiver) external payable {

    require (msg.value > 0);
    sender = msg.sender;
    receiver = _receiver;   

function viewApprover () external pure returns(address) {

function approve() external {
        require(msg.sender == approver);

Here the picture from the result of trying to compile the solidity contract:

enter image description here

2 Answers 2


Should be

function deposit(address payable _receiver) external payable {

From Solidity documentation:

The address type comes in two flavours, which are largely identical:

address: Holds a 20 byte value (size of an Ethereum address).

address payable: Same as address, but with the additional members transfer and send.

The idea behind this distinction is that address payable is an address you can send Ether to, while a plain address cannot be sent Ether.

Since address has fewer methods than address payable, you cannot directly assign address value to address payable variable, though you may explicitly cast address to address payable (not needed in your case).

  • It's works, OMG, it took me 4h for this
    – sohd9
    Commented Apr 4, 2019 at 9:46
  • 5
    How would you cast address to address payable? Commented Feb 20, 2020 at 23:16
  • 9
    cast address to address payable using payable(msg.sender) Commented Apr 16, 2021 at 21:52
  • @NYCTechEngineer this answer helps too. Commented Aug 30, 2021 at 10:02

This casting worked for me:

casted "address" to "address payable" with "payable(msg.sender)".

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