Skip to content

Instantly share code, notes, and snippets.

@gwmccubbin
Created April 27, 2020 15:08
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwmccubbin/58daa4df776c6d6b4b7a261db8ecad72 to your computer and use it in GitHub Desktop.
Save gwmccubbin/58daa4df776c6d6b4b7a261db8ecad72 to your computer and use it in GitHub Desktop.
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