Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update erc20_tutorial.sol #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 18 additions & 104 deletions contracts/erc20_tutorial.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pragma solidity ^0.4.24;
programa solidity ^0.4.24;

// ----------------------------------------------------------------------------
// '0Fucks' token contract
// 'FURIOUS COIN ' token contract
//
// Deployed to : 0x5A86f0cafD4ef3ba4f0344C138afcC84bd1ED222
// Symbol : 0FUCKS
// Name : 0 Fucks Token
// Total supply: 100000000
// Decimals : 18
// Deployed to : 0xa6249C9044caaB34a1875A6e0db9a17Ffc7DAaCB
// Symbol : FRC
// Name : FURIOUS COIN Token
// Total supply: 1900000000
// Decimals : 08
//
// Enjoy.
//
Expand Down Expand Up @@ -39,7 +39,7 @@ contract SafeMath {


// ----------------------------------------------------------------------------
// ERC Token Standard #20 Interface
// ERC Standard #20 Interface
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// ----------------------------------------------------------------------------
contract ERC20Interface {
Expand All @@ -52,8 +52,8 @@ contract ERC20Interface {

event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}

{

// ----------------------------------------------------------------------------
// Contract function to receive approval and execute function in one call
Expand Down Expand Up @@ -94,12 +94,11 @@ contract Owned {
}
}


// ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ----------------------------------------------------------------------------
contract FucksToken is ERC20Interface, Owned, SafeMath {
contract FURIOUS COIN is ERC20Interface, Owned, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
Expand All @@ -112,17 +111,16 @@ contract FucksToken is ERC20Interface, Owned, SafeMath {
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "0FUCKS";
name = "0 Fucks Token";
decimals = 18;
_totalSupply = 100000000000000000000000000;
balances[0x5A86f0cafD4ef3ba4f0344C138afcC84bd1ED222] = _totalSupply;
emit Transfer(address(0), 0x5A86f0cafD4ef3ba4f0344C138afcC84bd1ED222, _totalSupply);
function FURIOUS COIN TOKEN() public {
symbol = "FRC";
name = "FURIOUS COIN TOKEN ";
decimals = 08;
_totalSupply = 1900000000;
balances[0xa6249C9044caaB34a1875A6e0db9a17Ffc7DAaCB] = _totalSupply;
emit Transfer(address(0), 0xa6249C9044caaB34a1875A6e0db9a17Ffc7DAaCB, _totalSupply);
}


// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
Expand All @@ -137,87 +135,3 @@ contract FucksToken is ERC20Interface, Owned, SafeMath {
return balances[tokenOwner];
}


// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}


// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}


// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}


// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}


// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}


// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}


// ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------
function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
}