LimitBalance.sol 747 B

12345678910111213141516171819202122232425262728293031
  1. pragma solidity ^0.4.18;
  2. /**
  3. * @title LimitBalance
  4. * @dev Simple contract to limit the balance of child contract.
  5. * @dev Note this doesn't prevent other contracts to send funds by using selfdestruct(address);
  6. * @dev See: https://github.com/ConsenSys/smart-contract-best-practices#remember-that-ether-can-be-forcibly-sent-to-an-account
  7. */
  8. contract LimitBalance {
  9. uint256 public limit;
  10. /**
  11. * @dev Constructor that sets the passed value as a limit.
  12. * @param _limit uint256 to represent the limit.
  13. */
  14. function LimitBalance(uint256 _limit) public {
  15. limit = _limit;
  16. }
  17. /**
  18. * @dev Checks if limit was reached. Case true, it throws.
  19. */
  20. modifier limitedPayable() {
  21. require(this.balance <= limit);
  22. _;
  23. }
  24. }