Created
July 29, 2018 05:22
-
-
Save yhuag/b28ab455f8080e81b20a61bec0eb6528 to your computer and use it in GitHub Desktop.
Demonstration for Workshop: Write and deploy your first smart contract in less than 30 minutes
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
/* | |
* Credit to: Ethereum | |
* Orginal source: https://www.ethereum.org/token | |
*/ | |
pragma solidity ^0.4.13; | |
contract Token { | |
mapping (address => uint256) public balances; | |
function Token(uint256 initialSupply) public { | |
balances[msg.sender] = initialSupply; | |
} | |
function transfer(address _to, uint256 _value) public { | |
require(balances[msg.sender] >= _value); | |
require(balances[_to] + _value >= balances[_to]); // Avoid overflows | |
balances[msg.sender] -= _value; | |
balances[_to] += _value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment