Secondary.sol 729 B

12345678910111213141516171819202122232425262728293031323334
  1. pragma solidity ^0.4.24;
  2. /**
  3. * @title Secondary
  4. * @dev A Secondary contract can only be used by its primary account (the one that created it)
  5. */
  6. contract Secondary {
  7. address private _primary;
  8. /**
  9. * @dev Sets the primary account to the one that is creating the Secondary contract.
  10. */
  11. constructor() public {
  12. _primary = msg.sender;
  13. }
  14. /**
  15. * @dev Reverts if called from any account other than the primary.
  16. */
  17. modifier onlyPrimary() {
  18. require(msg.sender == _primary);
  19. _;
  20. }
  21. function primary() public view returns (address) {
  22. return _primary;
  23. }
  24. function transferPrimary(address recipient) public onlyPrimary {
  25. require(recipient != address(0));
  26. _primary = recipient;
  27. }
  28. }