How to Launch Your Very Own Useless ERC-20 Token
By: Genson C. Glier
Tags: ICO, Blockchain, Cryptocurrency, Ethereum, Bitcoin

Fancy adding another pointless token to the 80,000+ Ethereum tokens in existence? Maybe you were inspired by the Useless Ethereum Token?

Creating a token has become easier than ever — follow this simple guide and you can launch your own ERC-20 token in less than an hour.

This will take you through the process from beginning to end, from just an idea to a fully-fledged token on Ethereum.

Before we begin, let’s get a bit of background knowledge clear.

1.Basic Concepts

What is an ERC-20 Token?

Is it a piece of software? Is it a piece of code? It’s actually just a technical specification. ERC-20 is a token protocol — it defines a common list of rules that all ERC-20 tokens have to follow.

ERC-20 tokens can be digital assets representing vouchers, values, IOUs, or even digital reflections of physical objects, but they are all governed by the same rules. This makes it possible for anyone with a little technical know-how to launch a token on the Ethereum network, and to understand how that token will behave.

Smart Contracts

Ethereum is built around the idea of Smart Contracts, which increase by an order of magnitude the potential applications of blockchain technology. A Smart Contract is just like any other contract, except it is written into the blockchain — the terms and agreement of buyers and sellers are directly written into lines of code.

This allows for transactions to be carried out without the need to trust a third-party, like a lawyer. Transactions are transparent, traceable, irreversible, and execute exactly as they have been setup to do.

Solidity

Solidity is a programming language for writing smart contracts, it is a unique programming language that is similar to Javascript (don’t worry, you don’t have to learn it for this guide!)

2.Before you Begin

Before you rush in, you should have an idea of how the token will fit into the bigger picture of your project. Make sure you get these details right!

Name: Another Useless Token

This is fairly straightforward. Get creative. it can be whatever you want, just try for something original to save confusion with existing tokens.

Symbol: ???

The most common length is three characters, though you can have a symbol as short as one character, or as long as nine (not recommended!)

Decimal Places: .0000000000000000001

Choose 0, and your your token is indivisible. Choose 18, and the least you can have is .0000000000000000001 of a token. Most tokens have 18 decimal places.

Keep in mind that the total supply is correlated to the number of decimal places — A token with 0 decimal places and a supply of 2000 will have a total supply of 2000. If you had a supply of 2000 tokens with 10 decimal places, then 10 zeros will be added to the amount: 2000,0000000000.

Number of Tokens in Circulation

Decide how how many tokens can be created (total supply). This depends on your business idea, and so you need a strategy in place before you get to this stage.

You should also consider what percentage of the tokens will be set aside for the owner, try not to go all Ripple and keep 50% of the tokens for yourself!

Anything else?

By this stage you should have an idea of the ICO start date and end date, and also an idea of the funding parameters — what is the minimum amount of money needed for the project to go ahead? And what is the maximum you want to collect?

You have to be quite arrogant not to set a maximum limit, and if you set the minimum too high you might fail to reach it.

3.Getting Technical

Don’t get too scared by the title, to avoid getting too technical we will use the TokenFactory template provided by Consensys.

This way there is no need to rewrite pre-existing code, and the process is simplified as much as possible. TokenFactory provide the source, and you just need to copy and paste it in to Remix and add your own details under the sections marked ‘CHANGE THESE VALUES.’

Embed Text here:

pragma solidity ^0.4.4;

contract Token {

/// @return total amount of tokens

function totalSupply() constant returns (uint256 supply) {}

/// @param _owner The address from which the balance will be retrieved

/// @return The balance

function balanceOf(address _owner) constant returns (uint256 balance) {}

/// @notice send `_value` token to `_to` from `msg.sender`

/// @param _to The address of the recipient

/// @param _value The amount of token to be transferred

/// @return Whether the transfer was successful or not

function transfer(address _to, uint256 _value) returns (bool success) {}

/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`

/// @param _from The address of the sender

/// @param _to The address of the recipient

/// @param _value The amount of token to be transferred

/// @return Whether the transfer was successful or not

function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}

/// @notice `msg.sender` approves `_addr` to spend `_value` tokens

/// @param _spender The address of the account able to transfer the tokens

/// @param _value The amount of wei to be approved for transfer

/// @return Whether the approval was successful or not

function approve(address _spender, uint256 _value) returns (bool success) {}

/// @param _owner The address of the account owning tokens

/// @param _spender The address of the account able to transfer the tokens

/// @return Amount of remaining tokens allowed to spent

function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}

event Transfer(address indexed _from, address indexed _to, uint256 _value);

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



}

contract StandardToken is Token {

function transfer(address _to, uint256 _value) returns (bool success) {

//Default assumes totalSupply can’t be over max (2²⁵⁶ — 1).

//If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn’t wrap.

//Replace the if with this one instead.

//if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {

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 transferFrom(address _from, address _to, uint256 _value) returns (bool success) {

//same as above. Replace this line with the following if you want to protect against wrapping uints.

//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {

if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {

balances[_to] += _value;

balances[_from] -= _value;

allowed[_from][msg.sender] -= _value;

Transfer(_from, _to, _value);

return true;

} else { return false; }

}

function balanceOf(address _owner) constant returns (uint256 balance) {

return balances[_owner];

}

function approve(address _spender, uint256 _value) returns (bool success) {

allowed[msg.sender][_spender] = _value;

Approval(msg.sender, _spender, _value);

return true;

}

function allowance(address _owner, address _spender) constant returns (uint256 remaining) {

return allowed[_owner][_spender];

}

mapping (address => uint256) balances;

mapping (address => mapping (address => uint256)) allowed;

uint256 public totalSupply;

}

//name this contract whatever you’d like

contract ERC20Token is StandardToken {

function () {

//if ether is sent to this address, send it back.

throw;

}

/* 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; //fancy name: eg Simon Bucks

uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It’s like comparing 1 wei to 1 ether.

string public symbol; //An identifier: eg SBX

string public version = ‘H1.0’; //human 0.1 standard. Just an arbitrary versioning scheme.

//

// CHANGE THESE VALUES

//

//make sure this function name matches the contract name above. So if you’re token is called UselessToken, make sure the //contract name above is also UselessToken instead of ERC20Token

function ERC20Token(

) {

balances[msg.sender] = NUMBER_OF_TOKENS_HERE; // Give the creator all initial tokens (100000 for example)

totalSupply = NUMBER_OF_TOKENS_HERE; // Update total supply (100000 for example)

name = “NAME OF YOUR TOKEN HERE”; // Set the name for display purposes

decimals = 0; // Amount of decimals for display purposes

symbol = “SYM”; // Set the symbol for display purposes

}

/* Approves and then calls the receiving contract */

function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {

allowed[msg.sender][_spender] = _value;

Approval(msg.sender, _spender, _value);

//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn’t have to include a contract in here just for this.

//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)

//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.

if(!_spender.call(bytes4(bytes32(sha3(“receiveApproval(address,uint256,address,bytes)”))), msg.sender, _value, this, _extraData)) { throw; }

return true;

}

}

4. Editing Code in Remix

Remix is an in browser IDE (Integrated Development Environment) for Ethereum, it lets us publish the token contract to the blockchain.

Copy the completed code into Solidity Remix and replace the bits marked “CHANGE THESE VALUES.”

Once you’ve swapped your details in, it’s time for the Testnet!

5. Deploying Token to the Testnet

The Testnet is the Ethereum test network, a play area for developers to test out ideas without actually putting them into production. Ether is free on the test network, so you can test your token without paying Gas fees!

There are three test networks with different advantages, but we are going to use Ropsten.

Log into Ropsten with Metamask

If you don’t have MetaMask, then it only takes five minutes to get the chrome add-on. This allows you to interact with the Ethereum blockchain in your browser.

Login to your MetaMask wallet and switch the main Ethereum network to Ropsten Test Net. Tokens allocated to the owner of the contract will be sent to this wallet.

Create the Token

Now go back to Remix, Go to the ‘Run’ tab and hit ‘Create’.

MetaMask will pop-up asking you to confirm and pay for the transaction.

You may need to visit the Ropsten Testnet faucet to get some free Ether to power the transaction.

Hit ‘Submit’ and then click the date to bring up the transaction in EtherScan.

Once the transaction has finished processing, the tokens that you set aside for the owner should be available in your MetaMask wallet.

To see them you will need to copy the contract address from the transaction information in Etherscan, and paste it into the MetaMask ‘Tokens’ tab.

Just hit ‘add’, and boom! Your tokens should appear!

6. Verifying Source Code

Verifying is an important step to ensure that Etherscan displays your token correctly. On the Ropsten Testnet, search for your token with the token address, and choose ‘Verify and Publish’ under ‘Code’.

It will then take you to another window for verifying the Solidity Source Code. Note, this is where you are likely to encounter problems if you are not very technical!

7. Deploying Token to the Mainnet

Follow steps 3–6 for deploying the token to the Testnet, but instead of choosing the Ropsten Testnet in MetaMask, choose the MainNet. This will incur a small Gas charge for processing.

8. Verifying on Etherscan

Once it’s on the Mainnet, and you have an ICO website, you can get your token a little logo, and full etherscan verification, by sending etherscan an email with these details:

1. Ensure that token contract source code has been verified

2. Official Site URL:

3. Contract Address:

4. Link to download a 28x28png icon logo:

Congratulations on adding another token to the network!