-
-
Save chriseth/19808389ad6de69b35480981d3aa8b9e to your computer and use it in GitHub Desktop.
EasterHeggs
This file contains hidden or 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.0; | |
contract EasterHeggs { | |
event Transfer(address indexed _from, address indexed _to, uint256 _value); | |
string public constant name = "EasterHeggs"; | |
string public constant symbol = "EHG"; | |
uint8 public constant decimals = 0; | |
/// The main balances / accounting mapping. | |
mapping(address => uint256) balances; | |
uint public totalSupply; | |
/// @return the Hegg balance of a given account. | |
function balanceOf(address _account) view public returns (uint256) { | |
return balances[_account]; | |
} | |
/// Transfer some heggs from one account to another. | |
function transfer(address _to, uint256 _value) public returns (bool success) { | |
if (balances[msg.sender] >= _value) { | |
balances[msg.sender] -= _value; | |
balances[_to] += _value; | |
emit Transfer(msg.sender, _to, _value); | |
return true; | |
} else | |
return false; | |
} | |
/// Internal function to create a new hegg. | |
function layHegg(address _recipient) internal { | |
balances[msg.sender] += 1; | |
totalSupply += 1; | |
emit Transfer(0, _recipient, 1); | |
} | |
event HeggRequested(address account, bytes32 name); | |
function requestHegg() public { | |
require(now <= 1522692000); // Only until 2018-04-02 18:00 UTC | |
bytes32 requestorName = NamedAccount(msg.sender).name(); | |
emit HeggRequested(msg.sender, requestorName); | |
layHegg(msg.sender); | |
} | |
} | |
contract NamedAccount { | |
function name() public view returns (bytes32); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment