Created
March 1, 2017 05:23
-
-
Save iisaint/01000ee83df44578dab79714b9e01cec to your computer and use it in GitHub Desktop.
A simple smart contract
This file contains hidden or 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.8; | |
| /* | |
| * Basic token | |
| * Basic version of StandardToken, with no allowances | |
| */ | |
| contract BasicToken { | |
| address public owner; | |
| uint public totalSupply; | |
| mapping(address => uint) balances; | |
| event Transfer(address indexed from, address indexed to, uint value); | |
| function BasicToken() { | |
| owner = msg.sender; | |
| balances[owner] = 10000; | |
| } | |
| function transfer(address _to, uint _value) { | |
| balances[msg.sender] = safeSub(balances[msg.sender], _value); | |
| balances[_to] = safeAdd(balances[_to], _value); | |
| Transfer(msg.sender, _to, _value); | |
| } | |
| function balanceOf(address _owner) constant returns (uint balance) { | |
| return balances[_owner]; | |
| } | |
| function safeSub(uint a, uint b) internal returns (uint) { | |
| assert(b <= a); | |
| return a - b; | |
| } | |
| function safeAdd(uint a, uint b) internal returns (uint) { | |
| uint c = a + b; | |
| assert(c>=a && c>=b); | |
| return c; | |
| } | |
| function assert(bool assertion) internal { | |
| if (!assertion) { | |
| throw; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment