Created
April 27, 2020 15:08
-
-
Save gwmccubbin/58daa4df776c6d6b4b7a261db8ecad72 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
contract Ownable { | |
address public 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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment