-
Notifications
You must be signed in to change notification settings - Fork 2
/
Lock.sol
26 lines (20 loc) · 833 Bytes
/
Lock.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;
// Import the "Ownable" interface from OpenZeppelin, that implements
// the "onlyOwner" modifier we use to make sure only the contract
// owner can operate the smart-lock
import "@openzeppelin/contracts/access/Ownable.sol";
/**
* @title Simple Smart-Lock
* @dev Very simple smart contract to manage the state of a smart-lock
*/
contract Lock is Ownable {
/** Store the smart lock state */
bool private _open;
/** Initialise the lock in a closed state */
constructor (bool open) { _open = open; }
/** Sets the state of the lock */
function setState(bool open) public onlyOwner() { _open = open; }
/** Returns true if the lock is open */
function isOpen() public view onlyOwner() returns (bool) { return _open == true; }
}