Created
October 8, 2019 16:14
-
-
Save StephenButtolph/732f30185fd97b026b53837c8f8042b1 to your computer and use it in GitHub Desktop.
A simple address registry contract for Ethereum
This file contains 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.4.22 <0.6.0; | |
contract registry { | |
address[] public addresses; | |
mapping(address => bool) public contains; | |
function register() public { | |
require(!contains[msg.sender]); | |
contains[msg.sender] = true; | |
addresses.push(msg.sender); | |
} | |
function getSize() public view returns (uint) { | |
return addresses.length; | |
} | |
function getWinner(uint index) public view returns (address) { | |
return addresses[index]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment