mirror of openzeppelin-contracts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openzeppelin-contracts/contracts/ownership/HasNoEther.sol

42 lines
1.3 KiB

pragma solidity ^0.4.24;
8 years ago
import "./Ownable.sol";
/**
* @title Contracts that should not own Ether
* @author Remco Bloemen <remco@2π.com>
* @dev This tries to block incoming ether to prevent accidental loss of Ether. Should Ether end up
7 years ago
* in the contract, it will allow the owner to reclaim this Ether.
* @notice Ether can still be sent to this contract by:
* calling functions labeled `payable`
* `selfdestruct(contract_address)`
* mining directly to the contract address
*/
8 years ago
contract HasNoEther is Ownable {
/**
* @dev Constructor that rejects incoming Ether
* The `payable` flag is added so we can access `msg.value` without compiler warning. If we
* leave out payable, then Solidity will allow inheriting contracts to implement a payable
* constructor. By doing it this way we prevent a payable constructor from working. Alternatively
* we could use assembly to access msg.value.
*/
constructor() public payable {
require(msg.value == 0);
8 years ago
}
/**
7 years ago
* @dev Disallows direct send by setting a default function without the `payable` flag.
*/
8 years ago
function() external {
}
/**
* @dev Transfer all Ether held by the contract to the owner.
*/
8 years ago
function reclaimEther() external onlyOwner {
owner.transfer(address(this).balance);
8 years ago
}
}