-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsurveillance-cameraV1.sol
72 lines (54 loc) · 2.28 KB
/
surveillance-cameraV1.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
import "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
import "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Receiver.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract SmartContract is ERC1155, ERC1155Receiver, Ownable {
string private _cameraName;
uint256 private _lastOnTime;
uint256 private _lastOffTime;
constructor(address _cameraOwner, string memory _name) ERC1155("") {
transferOwnership(_cameraOwner);
_cameraName = _name;
}
function setCameraOwner(address _newOwner) public onlyOwner {
transferOwnership(_newOwner);
}
function getCameraOwner() public view returns (address) {
return owner();
}
function getCameraName() public view returns (string memory) {
return _cameraName;
}
function turnOn() public onlyOwner {
_lastOnTime = block.timestamp;
}
function turnOff() public onlyOwner {
_lastOffTime = block.timestamp;
}
function getLastOnTime() public view returns (uint256) {
return _lastOnTime;
}
function getLastOffTime() public view returns (uint256) {
return _lastOffTime;
}
function getTokenURI(uint256 tokenId) public view override returns (string memory) {
return "";
}
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return super.supportsInterface(interfaceId);
}
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override(ERC1155, ERC1155Receiver) {
super._beforeTokenTransfer(from, to, tokenId);
}
function _onTokenTransfer(address operator, address from, uint256 id, uint256 value, bytes calldata data) internal virtual override(ERC1155Receiver) {
super._onTokenTransfer(operator, from, id, value, data);
}
function _onTokenBatchTransfer(address operator, address from, uint256[] memory ids, uint256[] memory values, bytes memory data) internal virtual override(ERC1155Receiver) {
super._onTokenBatchTransfer(operator, from, ids, values, data);
}
function withdraw() public onlyOwner {
payable(owner()).transfer(address(this).balance);
}
receive() external payable {}
}