Last active
March 27, 2018 05:15
-
-
Save devonwesley/d9e99eac8e10c46b7e61d6b29a23da3f to your computer and use it in GitHub Desktop.
This is a basic token contract provided by the OpenZeppelin team.
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.18; | |
contract BasicToken { | |
mapping(address => uint256) balances; | |
string public constant NAME = "BasicToken"; | |
string public constant SYMBOL = "BTN"; | |
uint256 totalSupply_; | |
event Transfer(address indexed from, address indexed to, uint256 value); | |
function BasicToken (uint256 INITIAL_SUPPLY, address _owner) { | |
totalSupply_ = INITIAL_SUPPLY; | |
balances[_owner] = INITIAL_SUPPLY; | |
Transfer(0x0, _owner, INITIAL_SUPPLY); | |
} | |
function totalSupply() public view returns (uint256) { | |
return totalSupply_; | |
} | |
function transfer(address _to, uint256 _value) public returns (bool) { | |
require(_to != address(0)); | |
require(_value <= balances[msg.sender]); | |
balances[msg.sender] = balances[msg.sender] - _value; | |
balances[_to] = balances[_to] + _value; | |
Transfer(msg.sender, _to, _value); | |
return true; | |
} | |
function balanceOf(address _owner) public view returns (uint256 balance) { | |
return balances[_owner]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment