---
title: "Comment by Jimi S on \"How to build your own Ethereum based ERC20 Token and launch an ICO in next 20 minutes\" | Hashnode"
description: "Awesome read so far! I have a question though: my current code does not want to distribute any of the tokens in response to Ether transactions. I&#39;ve sent a"
url: "https://hashnode.com/posts/how-to-build-your-own-ethereum-based-erc20-token-and-launch-an-ico-in-next-20-minutes/5a38344e912627e67468a2c4/comment/5a80c18278dcafc230d41b50"
---

[Discussion](https://hashnode.com/posts/how-to-build-your-own-ethereum-based-erc20-token-and-launch-an-ico-in-next-20-minutes/5a38344e912627e67468a2c4)

Comment [How to build your own Ethereum based ERC20 Token and launch an ICO in next 20 minutes](https://hashnode.com/posts/how-to-build-your-own-ethereum-based-erc20-token-and-launch-an-ico-in-next-20-minutes/5a38344e912627e67468a2c4)

[Jimi S](https://hashnode.com/@Malauw)

[Feb 11, 2018](https://hashnode.com/posts/how-to-build-your-own-ethereum-based-erc20-token-and-launch-an-ico-in-next-20-minutes/5a38344e912627e67468a2c4/comment/5a80c18278dcafc230d41b50)

Awesome read so far! I have a question though: my current code does not want to distribute any of the tokens in response to Ether transactions. I've sent a few Ether from various test accounts to the contract, but the contract won't send any of the tokens back. What am I doing wrong? My code:

Edit: The Ether also seems to be stuck at the contract address and is not being send to the address that has created the contract.

```
pragma solidity ^0.4.4;

contract Token {

function totalSupply() constant returns (uint256 supply) {}
function balanceOf(address _owner) constant returns (uint256 balance) {}
function transfer(address _to, uint256 _value) returns (bool success) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}

contract StandardToken is Token {

function transfer(address _to, uint256 _value) returns (bool success) {
    if (balances[msg.sender] >= _value && _value > 0) {
        balances[msg.sender] -= _value;
        balances[_to] += _value;
        Transfer(msg.sender, _to, _value);
        return true;
    } else { return false; }
}

function balanceOf(address _owner) constant returns (uint256 balance) {
    return balances[_owner];
}

mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public totalSupply;
}

contract JIMI is StandardToken { // CHANGE THIS. Update the contract name.

/* Public variables of the token */

/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name = 'JIMI';                   // Token Name
uint8 public decimals = 0;                // How many decimals to show. To be standard complicant keep it 18
string public symbol = 'JIMI';                 // An identifier: eg SBX, XPR etc..
string public version = 'J1.0'; 
uint256 public unitsOneEthCanBuy;     // How many units of your coin can be bought by 1 ETH?
uint256 public totalEthInWei;         // WEI is the smallest unit of ETH (the equivalent of cent in USD or satoshi in BTC). We'll store the total ETH raised via our ICO here.  
address  fundsWallet = 0xb6F6d01aAf700C83819cE0707C6B69607AfF36a9;           // Where should the raised ETH go?

// This is a constructor function 
// which means the following function name has to match the contract name declared above
function JIMI() {
    balances[msg.sender] = 1000;               // Give the creator all initial tokens. This is set to 1000 for example. If you want your initial tokens to be X and your decimal is 5, set this value to X * 100000. (CHANGE THIS)
    totalSupply = 1000;                        // Update total supply (1000 for example) (CHANGE THIS)
    name = "JIMI";                                   // Set the name for display purposes (CHANGE THIS)
    decimals = 0;                                               // Amount of decimals for display purposes (CHANGE THIS)
    symbol = "JIMI";                                             // Set the symbol for display purposes (CHANGE THIS)
    unitsOneEthCanBuy = 100;                                      // Set the price of your token for the ICO (CHANGE THIS)
    fundsWallet = msg.sender;                                    // The owner of the contract gets ETH
}

function() payable{
    totalEthInWei = totalEthInWei + msg.value;
    uint256 amount = msg.value * unitsOneEthCanBuy;
    if (balances[fundsWallet] < amount) {
        return;
    }

    balances[fundsWallet] = balances[fundsWallet] - amount;
    balances[msg.sender] = balances[msg.sender] + amount;

    Transfer(fundsWallet, msg.sender, amount); // Broadcast a message to the blockchain

    //Transfer ether to fundsWallet
    fundsWallet.transfer(msg.value);                               
}
```

}

[Just Modifci](https://hashnode.com/@modifci)

[Feb 17, 2018](https://hashnode.com/posts/how-to-build-your-own-ethereum-based-erc20-token-and-launch-an-ico-in-next-20-minutes/5a38344e912627e67468a2c4/comment/5a80c18278dcafc230d41b50#reply-5a88b7a8473ee05c28725a05)

Same here

[Romain NEUVILLE](https://hashnode.com/@Holist)

[Jun 19, 2018](https://hashnode.com/posts/how-to-build-your-own-ethereum-based-erc20-token-and-launch-an-ico-in-next-20-minutes/5a38344e912627e67468a2c4/comment/5a80c18278dcafc230d41b50#reply-5b2964e62ffad6841dc7520c)

Same
