Skip to content
Permalink
Browse files

Updated to be compatible with wallet.ethereum.org

Please see this issue: #7
  • Loading branch information...
chrisdannen committed Feb 18, 2019
1 parent f9f9ee5 commit 72934fd217ea7565dc97aa4e1b4902bfe0102cfc
Showing with 12 additions and 31 deletions.
  1. +12 −31 mytoken.sol
@@ -1,41 +1,22 @@
pragma solidity ^0.4.0;
contract MyToken {
/* Public variables of the token */
string public name;
string public symbol;
uint8 public decimals;
pragma solidity >=0.4.22 <0.6.0;

contract MyToken {
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;

/* This generates a public event on the blockchain that will notify clients */
event Transfer(address indexed from, address indexed to, uint256 value);

/* Initializes contract with initial supply tokens to the creator of the contract */
constructor(uint256 _supply, string _name, string _symbol, uint8 _decimals) public {
/* if supply not given then generate 1 million of the smallest unit of the token */
if (_supply == 0) _supply = 1000000;

/* Unless you add other functions these variables will never change */
balanceOf[msg.sender] = _supply;
name = _name;
symbol = _symbol;

/* If you want a divisible token then add the amount of decimals the base unit has */
decimals = _decimals;
constructor(
uint256 initialSupply
) public {
balanceOf[msg.sender] = initialSupply; // Give the creator all initial tokens
}

/* Send coins */
function transfer(address _to, uint256 _value) public {
/* If the sender doesn't have enough balance then stop */
if (balanceOf[msg.sender] < _value) revert();
if (balanceOf[_to] + _value < balanceOf[_to]) revert();

/* Add and subtract new balances */
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;

/* Notify anyone listening that this transfer took place */
emit Transfer(msg.sender, _to, _value);
function transfer(address _to, uint256 _value) public returns (bool success) {
require(balanceOf[msg.sender] >= _value); // Check if the sender has enough
require(balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows
balanceOf[msg.sender] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
return true;
}
}

0 comments on commit 72934fd

Please sign in to comment.
You can’t perform that action at this time.