dapp-quiz/quiz/quiz.sol

27 lines
624 B
Solidity
Raw Normal View History

2023-09-28 10:41:29 +02:00
pragma solidity >=0.5.2 <0.9.0;
contract Quiz {
string public question;
bytes32 internal _answer;
mapping (address => bool) internal _leaderBoard;
constructor(string memory _qn, bytes32 _ans) {
question = _qn;
_answer = _ans;
}
function sendAnswer(bytes32 _ans) public returns (bool){
return _updateLeaderBoard(_answer == _ans);
}
function _updateLeaderBoard(bool ok) internal returns (bool){
_leaderBoard[msg.sender] = ok;
return true;
}
function checkBoard() public view returns (bool){
return _leaderBoard[msg.sender];
}
}