Skip to content

Instantly share code, notes, and snippets.

@yhuag
Created July 29, 2018 05:22
Show Gist options
  • Save yhuag/b28ab455f8080e81b20a61bec0eb6528 to your computer and use it in GitHub Desktop.
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
/*
* 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