pragma solidity ^0.4.23;

contract ApprovalContract {
address public sender;
address public receiver;

address public constant approver = 0x5AEDA56215b167893e80B4fE645BA6d5Bab767DE;

constructor() public {
// tbd
function deposit(address _receiver) external payable {
    require(msg.value > 0);
    sender = msg.sender;
    receiver = _receiver;

function viewApprover() external pure returns(address){

function viewRe() external pure returns(address){

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

    receiver.transfer(address(this).balance); // this line not working


I am getting transfer variable not visible.

Member "transfer" not found or not visible after argument-dependent lookup in address.



address payable public receiver;

in declaration for the addresses you are looking to transfer Ether in contract. As per the 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.

| improve this answer | |
  • 1
    That's true in Solidity 0.5.x, but the original code in the question appears to be using Solidity 0.4.x, where address payable does not yet exist. That said, the original code compiles fine in 0.4.x modulo a pure that should be a view. So I don't know which compiler version is actually being used. :-) – user19510 Dec 5 '18 at 16:07
  • IMO only case in which error can appear is when compiler is 0.5.0. @sumeet Please clarify it – Aniket Dec 5 '18 at 17:08
  • 3
    Just because it says pragma solidity ^0.4.23; doesn't mean it's using that version. If the contract is being imported into another contract that has a 0.5.0 compiler version, then it'll be compiled with 0.5.0 and throw this error. – flygoing Dec 5 '18 at 17:50

You can always cast address to payable address:

| improve this answer | |

You can try these... Just by changing last line.

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

} }

| improve this answer | |

It worked for me following this code..

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

| improve this answer | |

Change address public receiver to address payable receiver.

| improve this answer | |

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.