Skip to content

Instantly share code, notes, and snippets.

@devonwesley
Last active March 27, 2018 05:15
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 devonwesley/d9e99eac8e10c46b7e61d6b29a23da3f to your computer and use it in GitHub Desktop.
Save devonwesley/d9e99eac8e10c46b7e61d6b29a23da3f to your computer and use it in GitHub Desktop.
This is a basic token contract provided by the OpenZeppelin team.
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