-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMySecretVault.sol
45 lines (38 loc) · 1.31 KB
/
MySecretVault.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
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
contract MySecretVault {
string private mySecretPassword;
address private owner;
mapping(address => bool) private isPasswordGiven;
uint256 private passwordGivenCount;
constructor(string memory _secretString) {
mySecretPassword = _secretString;
owner = msg.sender;
}
function givePassword(
string memory _fistDoor,
string memory _secondDoor
) public returns (string memory) {
require(
keccak256(abi.encodePacked(_fistDoor)) ==
keccak256(abi.encodePacked("La peau")),
"Quel est le premier mot magique ?"
);
require(
keccak256(abi.encodePacked(_secondDoor)) ==
keccak256(abi.encodePacked("de chagrin")),
"Quel est le second mot magique ?"
);
isPasswordGiven[msg.sender] = true;
passwordGivenCount++;
return mySecretPassword;
}
function checkPasswordGiven(address _address) public view returns (bool) {
require(msg.sender == owner, "Chenapan !");
return isPasswordGiven[_address];
}
function getPasswordGivenCount() public view returns (uint256) {
require(msg.sender == owner, "Sacripant !");
return passwordGivenCount;
}
}