Skip to content

Instantly share code, notes, and snippets.

@letsgitcracking
Last active October 25, 2022 17:54
Show Gist options
  • Save letsgitcracking/a7d3d62df2d4a13f6b1cf9991da795d9 to your computer and use it in GitHub Desktop.
Save letsgitcracking/a7d3d62df2d4a13f6b1cf9991da795d9 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.17;
/*
Congratulations you have found the Treasure Chest contract.
You now need to make an interface contract to interact with the
getTreasure method in this contract. Please look at the gist given
during lesson for an example of an interface.
*/
interface ITeamRegistration {
function registeredList(address) external view returns (bool);
}
contract TreasureChest {
address immutable _owner;
address TeamRegistrationContract;
event InterfaceAddressedSet();
event TreasureClaimed(address indexed, uint256 indexed, string indexed);
modifier onlyAdmin() {
require(msg.sender == _owner, "Not owner");
_;
}
constructor() {
_owner = msg.sender;
}
function setInterfaceAddress(address _address) external onlyAdmin {
TeamRegistrationContract = _address;
emit InterfaceAddressedSet();
}
function GetTreasure(address sender) external {
require(ITeamRegistration(TeamRegistrationContract).registeredList(sender), "EOA is not registered!");
emit TreasureClaimed(msg.sender, block.timestamp, "Well done!!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment