Author

Topic: Help me create a eth token (for educational purposes only) (Read 220 times)

newbie
Activity: 5
Merit: 0
hi
i've been trying to create my own ehterum token (just for educational purposes) but still cant get it
what i am doeing wrong? share you the code, it just do not compile Sad

I dont need it to be an "ICO" token, i just want to have it in my wallet and be able to send it to other wallets


pragma solidity ^0.4.7;


contract SafeMath {
 function safeMul(uint a, uint b) internal returns (uint) {
        uint c = a * b;
        assert(a ==0 || c / a ==b);
        return c;
    } 
    function safeDiv(uint a, uint b) internal returns (uint) {
        assert(b > 0);
        uint c = a / b;
        assert(a == b * c + a % b);
        return c;
    }
    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);
        return c;
    }
   
    function max64(uint64 a, uint64 b) internal constant returns (uint64) {
        return a >= b ? a : b;
    }
    function min64(uint64 a, uint64 b) internal constant returns (uint64){
        return a < b ? a : b;
    }
    function max256(uint256 a, uint256 b) internal constant returns (uint256) {
        return a >= b ? a : b;
    }
   
    function min256(uint256 a, uint256 b) internal constant returns (uint256) {
        return a < b ? a : b;
    }
}
   
 contract ERC20Basic {
    uint public totalSupply;
    function balanceOf(address who) constant return (uint);
    function transfer(address to, uint value);
    event tranfer(adress indexed from, adress indexed to, uint value);
}

contract ERC20 is ERC20Basic {
    function allowance(address owner, address spender) constant returns (uint);
   
    function tranferFrom(address from, address to, uint value);
    function approve(adreess spender, uint value);
    event Approval(address indexed owner, address indexed spender, uint value);
}

contract BasicToken is ERC20Basic, SafeMath {
    mapping(address => uint) balances;
   
    modifier onlyPayloadSize(uint size) {
        assert(msg.data.lenght >= size + 4);
        _;
    }
    function transfer(address _to, uint _value) onlyPayloadSize(2*32) {
        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];
    }
}

contract StandardToken is BasicToken, ERC20 {
   
    mapping (address => mapping (address => uint)) allowed;
   
    function transferFrom(address _from, address _to, uint _value){
      var _allowance = allowed[_from][msg.sender];
        balances[_to] = safeAdd(balances[_to], _value);
        balances[_from] = safeSub(balances[_from], _value);
        allowed[_from][msg.sender] = safeSub(_allowance, _value);
        Transfer(_from, _to, _value); 
    }
   
    function approve(address _spender, uint _value) {
        allowed[msg.sender][_spender] = _value;
        Approval(msg.sender, _spender, _value);
    }
   
   function allowance(address _owner, address _spender) constant returns (uint remaining) {
       return allowed[_owner][_spender];
   }
   
}

contract SimpleToken is StandardToken {
   
    string public name = "justatoken";
    string public symbol = "tkn";
    uint public decimals = 3;
    uint public INITIAL_SUPPLY = 100000;
   
    function SimpleToken() {
        totalSUpply = INITIAL_SUPPLY;
        balances[msg.sender] = INITIAL_SUPPLY;
    }
}

thanks
Jump to: