Skip to content

Commit

Permalink
ERC20 standard function
Browse files Browse the repository at this point in the history
  • Loading branch information
maciukaite committed Oct 30, 2017
1 parent 6324dcc commit acfe02a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 34 deletions.
2 changes: 2 additions & 0 deletions ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ contract ERC20 {

event Approval(address indexed _owner, address indexed _spender, uint256 _value);

function totalSupply() external constant returns (uint);

function balanceOf(address _owner) external constant returns (uint256);

function transfer(address _to, uint256 _value) external returns (bool);
Expand Down
16 changes: 8 additions & 8 deletions GEEToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ contract GEEToken is MigratableToken {
uint256 private constant DENOMINATOR = 1000;

function GEEToken() {
uint256 icoAndCommunityTokens = totalSupply * ICO_AND_COMMUNITY_THOUSANDTH / DENOMINATOR;
//88% of totalSupply
uint256 icoAndCommunityTokens = _totalSupply * ICO_AND_COMMUNITY_THOUSANDTH / DENOMINATOR;
//88% of _totalSupply
balances[msg.sender] = icoAndCommunityTokens;
//2.4% of totalSupply
balances[TEAM0] = totalSupply * TEAM0_THOUSANDTH / DENOMINATOR;
//3.6% of totalSupply
team1Balance = totalSupply * TEAM1_THOUSANDTH / DENOMINATOR;
//6% of totalSupply
team2Balance = totalSupply * TEAM2_THOUSANDTH / DENOMINATOR;
//2.4% of _totalSupply
balances[TEAM0] = _totalSupply * TEAM0_THOUSANDTH / DENOMINATOR;
//3.6% of _totalSupply
team1Balance = _totalSupply * TEAM1_THOUSANDTH / DENOMINATOR;
//6% of _totalSupply
team2Balance = _totalSupply * TEAM2_THOUSANDTH / DENOMINATOR;

Transfer (this, msg.sender, icoAndCommunityTokens);
}
Expand Down
2 changes: 1 addition & 1 deletion MigratableToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ contract MigratableToken is Token {
//Migrates user balance
balances[msg.sender] = balances[msg.sender].SUB(_value);
//Migrates total supply
totalSupply = totalSupply.SUB(_value);
_totalSupply = _totalSupply.SUB(_value);
//Counts migrated tokens
totalMigrated = totalMigrated.ADD(_value);
//Upgrade agent reissues the tokens
Expand Down
52 changes: 30 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ This contract defines a standard ERC20 token with some extra functionalities. Th

#### **Variables**
```javascript
uint256 public totalSupply = 100 * (10**6) * (10**8);
uint256 public _totalSupply = 100 * (10**6) * (10**8);
```
Total supply of tokens is 100 million.
<br>
Expand Down Expand Up @@ -136,6 +136,14 @@ event Burn(address indexed _from, uint256 _value);
The event that is triggered when tokens are burned. The indexed parameters allow filtering events by specific addresses.
<br>
<br>
```javascript
function totalSupply() external constant returns (uint256 totalTokenSupply) {
totalTokenSupply = _totalSupply;
}
```
A function that return total supply of the token.
<br>
<br>
#### **Functions**
```javascript
function transfer(address _to, uint256 _amount)
Expand Down Expand Up @@ -239,15 +247,15 @@ To decrease allowed value is better to use this function to avoid 2 calls (and w
<br>
<br>
```javascript
function burn(uint256 _value) external returns (bool success) {
require(trusted[msg.sender]);
//Subtract from the sender
balances[msg.sender] = balances[msg.sender].SUB(_value);
//Update totalSupply
totalSupply = totalSupply.SUB(_value);
Burn(msg.sender, _value);
return true;
}
function burn(uint256 _value) external returns (bool success) {
require(trusted[msg.sender]);
//Subtract from the sender
balances[msg.sender] = balances[msg.sender].SUB(_value);
//Update _totalSupply
_totalSupply = _totalSupply.SUB(_value);
Burn(msg.sender, _value);
return true;
}
```
Allows trusted address burning a specific amount of his tokens. This function is intended to be called after the Crowdsale to burn the unsold tokens.
<br>
Expand Down Expand Up @@ -394,17 +402,17 @@ uint256 private constant DENOMINATOR = 1000;
#### **Functions**
```javascript
function GEEToken() {
uint256 icoAndCommunityTokens = totalSupply * ICO_AND_COMMUNITY_THOUSANDTH / DENOMINATOR;
//88% of totalSupply
balances[msg.sender] = icoAndCommunityTokens;
//2.4% of totalSupply
balances[TEAM0] = totalSupply * TEAM0_THOUSANDTH / DENOMINATOR;
//3.6% of totalSupply
team1Balance = totalSupply * TEAM1_THOUSANDTH / DENOMINATOR;
//6% of totalSupply
team2Balance = totalSupply * TEAM2_THOUSANDTH / DENOMINATOR;

Transfer (this, msg.sender, icoAndCommunityTokens);
uint256 icoAndCommunityTokens = _totalSupply * ICO_AND_COMMUNITY_THOUSANDTH / DENOMINATOR;
//88% of _totalSupply
balances[msg.sender] = icoAndCommunityTokens;
//2.4% of _totalSupply
balances[TEAM0] = _totalSupply * TEAM0_THOUSANDTH / DENOMINATOR;
//3.6% of _totalSupply
team1Balance = _totalSupply * TEAM1_THOUSANDTH / DENOMINATOR;
//6% of _totalSupply
team2Balance = _totalSupply * TEAM2_THOUSANDTH / DENOMINATOR;

Transfer (this, msg.sender, icoAndCommunityTokens);
}
```
Upon creation of the contract, 88% of tokens are allocated to the owner of the contract, 3.6% to the first team wallet and 6% to the second team wallet.
Expand Down Expand Up @@ -1005,7 +1013,7 @@ function migrate(uint256 _value) external {
//Migrates user balance
balances[msg.sender] = balances[msg.sender].SUB(_value);
//Migrates total supply
totalSupply = totalSupply.SUB(_value);
_totalSupply = _totalSupply.SUB(_value);
//Counts migrated tokens
totalMigrated = totalMigrated.ADD(_value);
//Upgrade agent reissues the tokens
Expand Down
11 changes: 8 additions & 3 deletions Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ contract Token is ERC20, Pausable {
using SafeMath for uint256;

//Total amount of Gee
uint256 public totalSupply = 100 * (10**6) * (10**8);
uint256 public _totalSupply = 100 * (10**6) * (10**8);

//Iend of crowdsale
uint256 public constant ICO_END = 222222222;
Expand All @@ -26,6 +26,11 @@ contract Token is ERC20, Pausable {
//Notifies users about the amount burnt
event Burn(address indexed _from, uint256 _value);

//return _totalSupply of the Token
function totalSupply() external constant returns (uint256 totalTokenSupply) {
totalTokenSupply = _totalSupply;
}

//What is the balance of a particular account?
function balanceOf(address _owner)
external
Expand Down Expand Up @@ -131,8 +136,8 @@ contract Token is ERC20, Pausable {
require(trusted[msg.sender]);
//Subtract from the sender
balances[msg.sender] = balances[msg.sender].SUB(_value);
//Update totalSupply
totalSupply = totalSupply.SUB(_value);
//Update _totalSupply
_totalSupply = _totalSupply.SUB(_value);
Burn(msg.sender, _value);
return true;
}
Expand Down

0 comments on commit acfe02a

Please sign in to comment.