-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolc.sol
More file actions
69 lines (55 loc) · 1.84 KB
/
solc.sol
File metadata and controls
69 lines (55 loc) · 1.84 KB
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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
/*
IDEAccess.sol
A simple smart contract to register wallets for using a Solidity IDE.
- Wallets can initiate access once.
- Owner/admin can track registered users.
- Events emitted for each registration.
*/
contract IDEAccess {
address public owner;
// Track which wallets have initiated access
mapping(address => bool) public hasInitiated;
// Event emitted when a wallet initiates access
event AccessInitiated(address indexed user, uint256 timestamp);
// Optional: list of all registered users
address[] public registeredUsers;
modifier onlyOwner() {
require(msg.sender == owner, "Not contract owner");
_;
}
constructor() {
owner = msg.sender; // deployer is owner/admin
}
/**
* @dev Wallet initiates access to the IDE.
*/
function initiateAccess() external {
require(!hasInitiated[msg.sender], "Already initiated");
hasInitiated[msg.sender] = true;
registeredUsers.push(msg.sender);
emit AccessInitiated(msg.sender, block.timestamp);
}
/**
* @dev Check if a wallet has initiated access
*/
function checkAccess(address user) external view returns (bool) {
return hasInitiated[user];
}
/**
* @dev Get total registered users
*/
function getRegisteredUsers() external view returns (address[] memory) {
return registeredUsers;
}
/**
* @dev Optional: owner can revoke access
*/
function revokeAccess(address user) external onlyOwner {
require(hasInitiated[user], "User not registered");
hasInitiated[user] = false;
// Optionally, remove from registeredUsers array (more complex)
emit AccessInitiated(user, block.timestamp); // can emit event for tracking
}
}