-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFactoryPattern.sol
More file actions
41 lines (32 loc) · 883 Bytes
/
Copy pathFactoryPattern.sol
File metadata and controls
41 lines (32 loc) · 883 Bytes
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
pragma solidity >=0.4.22 <0.7.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 SecretContract 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();
}
}