-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStoreSecret.sol
52 lines (32 loc) · 938 Bytes
/
StoreSecret.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
pragma solidity ^0.6.0;
contract Ownable {
address owner;
constructor () public {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner, "must be owner");
_;
}
}
contract SecretVault {
string secret;
constructor (string memory _secret) public {
secret = _secret;
}
function getSecret() public view returns(string memory) {
return secret;
}
}
contract MyContract is Ownable {
address secretVault;
constructor(string memory _secret) public {
SecretVault _secretVault = new SecretVault(_secret);
secretVault = address(_secretVault);
super;
}
function getSecret() public view onlyOwner returns(string memory) {
SecretVault _secretVault = SecretVault(secretVault);
return _secretVault.getSecret();
}
}