Skip to content

Instantly share code, notes, and snippets.

@StephenButtolph
Created October 8, 2019 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StephenButtolph/732f30185fd97b026b53837c8f8042b1 to your computer and use it in GitHub Desktop.
Save StephenButtolph/732f30185fd97b026b53837c8f8042b1 to your computer and use it in GitHub Desktop.
A simple address registry contract for Ethereum
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