-
-
Save anonymous/11d37a7de527c8f80fb89c253ebaba4b to your computer and use it in GitHub Desktop.
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.11; | |
import '../dependencies/DBC.sol'; | |
import './PreminedAsset.sol'; | |
/// @title EtherToken Contract. | |
/// @author Melonport AG <team@melonport.com> | |
/// @notice Make Ether into a ERC20 compliant token | |
/// @notice Compliant to https://github.com/dapphub/ds-eth-token/blob/master/src/eth_wrapper.sol | |
contract EtherToken is DBC, PreminedAsset { | |
using safeMath for uint256; | |
// FIELDS | |
// Constant fields | |
string public constant name = "Ether Token"; | |
string public constant symbol = "ETH-T"; | |
uint public constant decimals = 18; | |
uint public constant preminedAmount = 10**28; | |
// EVENTS | |
event Deposit(address indexed who, uint amount); | |
event Withdrawal(address indexed who, uint amount); | |
// METHODS | |
function EtherToken() | |
PreminedAsset(name, symbol, decimals, preminedAmount) | |
{} | |
function() payable { deposit(); } | |
function deposit() | |
payable | |
{ | |
balances[msg.sender] = balances[msg.sender].add(msg.value); | |
Deposit(msg.sender, msg.value); | |
} | |
function withdraw(uint amount) | |
pre_cond(balances[msg.sender] >= amount) | |
{ | |
balances[msg.sender] = balances[msg.sender].sub(amount); | |
assert(msg.sender.send(amount)); | |
Withdrawal(msg.sender, amount); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment