0
pragma solidity ^0.4.11;

/**
 * @title Ownable
 * @dev The Ownable contract has an owner address, and provides basic authorization control
 * functions, this simplifies the implementation of "user permissions".
 */
contract Ownable {

 address public owner;

    /**
   * @dev The Ownable constructor sets the original `owner` of the contract to the sender
   * account.
   */
  function Ownable() {
    owner = msg.sender;
  }


  /**
   * @dev Throws if called by any account other than the owner.
   */
  modifier onlyOwner() {
    (msg.sender == owner);
    _;
  }


  /**
   * @dev Allows the current owner to transfer control of the contract to a newOwner.
   * @param newOwner The address to transfer ownership to.
   */
  function transferOwnership(address newOwner) onlyOwner {
   (newOwner != address(0));      
    owner = newOwner;
  }

}

/**
 * @title Destructible
 * @dev Base contract that can be destroyed by owner. All funds in contract will be sent to the owner.
 */
contract Destructible is Ownable {

  function Destructible() payable { } 

  /**
   * @dev Transfers the current balance to the owner and terminates the contract. 
   */
  function destroy() onlyOwner {
    selfdestruct(owner);
  }

  function destroyAndSend(address _recipient) onlyOwner {
    selfdestruct(_recipient);
  }
}

contract BankAccount is Ownable, Destructible {

  function store() public payable {

  } 

  function withdraw(uint amount) public onlyOwner {
      if (this.balance >= amount) {
       msg.sender.transfer(amount);
     }
  } 
 }

Error message

browser/Ownable.sol:69:8: Error: Member "transfer" not found or not visible after argument-dependent lookup in address
       msg.sender.transfer(amount);
       ^-----------------^
  • 1
    There does not seem to be any errors with this contract when compiled in Remix. You should clarify how you are getting the error you posted. – Shawn Tabrizi Feb 12 at 9:46
0

in withdraw function, contract itself sends ether to msg.sender. so Include payable() modifier to the function when sending ether takesplace..

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.