forked from nicobevilacqua/CaptureTheEtherHardhat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NicknameChallenge.sol
32 lines (26 loc) · 999 Bytes
/
NicknameChallenge.sol
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
pragma solidity ^0.4.21;
// Relevant part of the CaptureTheEther contract.
contract CaptureTheEther {
mapping(address => bytes32) public nicknameOf;
mapping(address => address) public playerNicknameContract;
function CaptureTheEther(address _player) public {
playerNicknameContract[_player] = new NicknameChallenge(_player);
}
function setNickname(bytes32 nickname) public {
nicknameOf[msg.sender] = nickname;
}
}
// Challenge contract. You don't need to do anything with this; it just verifies
// that you set a nickname for yourself.
contract NicknameChallenge {
CaptureTheEther cte = CaptureTheEther(msg.sender);
address player;
// Your address gets passed in as a constructor parameter.
function NicknameChallenge(address _player) public {
player = _player;
}
// Check that the first character is not null.
function isComplete() public view returns (bool) {
return cte.nicknameOf(player)[0] != 0;
}
}