Ethereum Tutorials

ICO TOOLKIT

OUR ICO

ICO Generator User Guide

ICO Generator is an online service that generates Solidity scripts for ICO Campaigns. Very often, a developer faces a situation when a client wants to launch an ICO, and requirements are changing "as we go". Or maybe you just want the job to be done FAST.

The idea behind ICO Generator tool is to allow the user to select features required for a particular campaign, like minimum and maximum goals, token name and so on. Then the Solidity contract is genegated automatically, and all that is left to do is to copy it and deploy.

On the following screenshot you see a typical view of an ICO Generator: the user set an "ICO" checkmark and specified campaign min. and max target as well as number of "shares" to issue (explained below).

Note that the "+" signs used to expand / collapse code fragments are there for reader's convenience only. When you believe that all features are specified, right before copying the code, you have to expand all collapsed sections.

ICO Generator Features

Let's walk through the features ICO Generator provides. First of all, some sections of the code are not possible to remove, as they are always required, no mater what features you select.

Safe Math

A small helper class, taking care of arithmetic overflow errors. Let's say you have a balance variable, and it is equal to 10. Then you (accidentally) subtract 20 from it. As Solidity does not have negative numbers, an overflow happens, and now the "balance" holde a REALLY large number. Which can create a disaster, as we are talking about money. SafeMath makes this situation impossible.

ERC20Interface

Think of an interface as of a reminder: here are functions you have to implement. By deriving our token (below) from ERC20Interface, we make sure that it is compatible with ERC20 standard.

ERC20Token

The interface does not have any implementation of functions, only the declarations. To implement them, we derive an ERC20Token class ("contract" in Solidity is the same as "class" in less financially oriented languages) from it and fill functions with the real code.

Ownable

Another standard class, used almost everywhere. It allows us to automatically set a contract owner to be the same person that created a class. The ownership can then be verified, so that sertain functions could be called only by the class owner.

The ownership can be transfered, but again, only by the current owner of a class.

Mintable

There are two major approaches to issuing tokens during the Crowd Funding. First, we initially generate maximum possible amount of tokens, and distribute whatever we can during the crowd sale. When crowd sale ends, we "burn" undistributed tokens.

The second approach, one used in ICO Generator tool, is to have no tokens at the beginning of a fund rising event, and to generate (or MINT) tokens as they are purchased. It means that at the end we don't have to "burn" nything.

Both methods work equally well, so it is a mater of personal preferences.

MyToken

"MyToken" is a default name for the token you create. To change it, enter another name in the "Token Name" edit box. The name you entered will replace the "MyToken" everywhere in the code.

Token (its parent class) has a "decimals" field specifying the number of decimal points to show to the user. For example, if you make coins (like Ethereum itself) you may want to allow it to have 18 digits after the decimal "dot" (like Ethereum does). While if you are selling movie tickets, the decimals should be zero, as there is no such thing as 1.235 movie tickets.

Decimals are used by online exchanges to display data properly: it is FOR HUMANS only, for our convenience.

ICO

As you can see, you don't have to have "ICO" checkbox selected: in that case you will only get the code for a token. Checking an "ICO" check box brings up options you can modify in your ICO contract, also it brings up the ICO code as well (initially collapsed).

Can pause Crowdsale

As your crowdsale goes, you might bump into some unexpected situations. Say, your web site is down or hacked. Anything. Then you can pause crowd sale, and resume it later. While paused, tokens can not be bought.

This feature works well with the next one, called "Can extend Crowdsale time" - if you lost some time due to site being down, why not to extend the Crowd Sale?

Can extend Crowdsale time

As was mentioned above, this option allows you to extend the duration of a crowd sale. To understand better the way it works, let's look at the Crowd Sale stages.

In the middle column of ICO Generator screen, you see the editable multiline text area containing a bracketed list:

{ 
	"status":"WAIT_PRESALE", 
	"timeEnd":"27 Nov 2018", 
	"tokenPrice":"1 finney",
    "tradingAllowed":"false"
}, 
{ 
	"status":"PRESALE", 
	"timeEnd":"27 Dec 2018", 
	"tokenPrice":"1 finney",
    "tradingAllowed":"true"
}, 
{ 
	"status":"WAIT_SALE", 
	"timeEnd":"27 Jan 2019", 
	"tokenPrice":"1 finney",
    "tradingAllowed":"false"
},
{ 
	"status":"SALE", 
	"timeEnd":"27 Feb 2019", 
	"tokenPrice":"1 finney",
    "tradingAllowed":"true"
},
{ 
	"status":"FINALIZING", 
	"timeEnd":"27 Mar 2019", 
	"tokenPrice":"1 finney",
    "tradingAllowed":"false"
} 

This is the list of stages of your ICO. As a minimum, you have to set correct dates there. Also keep attention on proper formatting, a missing quotation mark will stop the generator half way, yeilding the improper code.

Note, that some stages are allowed to do trading (selling tokens), while some are not. Also, you can set the price of a token on each stage (it will be ignored if trading is prohibited, but you still need to have this field).

Edit the text in an edit box, and press "Update ICO Prices & Timing" button. The changes will be reflected in the text.

How do I know that the code was generated without errors?

To find out if there were errors, at least in Windows - Chrome, press F12. It will open a Chrome's debug window (to hide it, press F12 again). If you see a red number in the corner, then there were errors.

After the "Update ICO Prices & Timing" button is pressed, the Solidity code is updated:

function ICO() public 
{
    m_token = new MyToken();
	m_saleOptions.push(SaleOptions("WAIT_PRESALE",1543266000,1000000000000000,0,0,false));,
    m_saleOptions.push(SaleOptions("PRESALE",1545858000,1000000000000000,0,0,true));,
    m_saleOptions.push(SaleOptions("WAIT_SALE",1548536400,1000000000000000,0,0,false));,
    m_saleOptions.push(SaleOptions("SALE",1551214800,1000000000000000,0,0,true));,
    m_saleOptions.push(SaleOptions("FINALIZING",1553634000,1000000000000000,0,0,false));
}

Note that in Solidity, dates are represented as seconds and mpney as wei (1 ether equals 10^18 wei).

Has Bonus Tokens

Often, Crowd Sale owner wants to issue some tokens free of charge to some people as a reward. For example, they have participated in beta testing, or advertizing campaign, or something else that deserves gratitude.

When you set a "Has Bonus Tokens" checkmark, the "ICO" class generated by an ICO Generator gets a "distributeTokens(address beneficiary, uint256 nNumOfTokens, string strDistributionReason)" function. It assigns the specified number of tokens to a specified address, free of charge. It is important that you specify a meaningful and consistent reason for token distribution, as it is being saved to the log and can then be used in reports.

ShareHolder Integration

A ShareHolder contract is a "smart contract 2.0" of a kind. See, after a crowd sale is over, tokens can be bought and sold on exchanges, at market price. However, they are not, in any way connected to an "underlying" company. Company is not regulated by law as would the "real life" company in case it issued "real life" shares. it does not pay any dividends... It can even to disappear in the thin air, instead of doing the job it raised funds for.

ShareHolder can help, at least in some cases. Particularly, it can provide a 100% protection of your interests in case the entire "underlying" business is located in a block chain. Think online Ethereim exchange or Casino. If this Casino is connected to ShareHolder (it should be written in its contract), then a specified part of its profit is directed there (by a contract! It can not be tampered with!) and then is distributed among share holders.

You can think of it as of shares, or as of a cumulative bank account.

And now the fun part.

As money can only go into ShareHolder shares, the price of a share can never go down. if you buy it, you can then sell it later at the same price (minus a small trade comission).

A next logical thing to do would be to distribute shares of a company you are about to create during a fund rising event.

Note that in this case your customer will not be able to sell these shares immediately, as there is no money behind it. But as your profit runs, shares price will increase and at some point the sale will be allowed (when an accumulated price will exceed the minimum stock price).

Configuring ShareHolder Integration

First of all, you will need a ShareHolder contract, which is a stand alone one. For details, see ShareHolder Tutorial.

Using the setShareHolder(address addr) function, set the ShareHolder contract that will serve the Crowd Sale.

Few words about the way shares are being assigned and removed, in case the crowd sale fails. first of all, you have two functions:
m_contractShareHolder.distributeBonusShares(msg.sender, nShares, m_strCampaignName);
and
m_contractShareHolder.undistributeBonusShares(m_strCampaignName);

First one distributes shares to token purchaser, the second one takes shares away. As one ShareHolder can serve nearly unlimited number of contracts (both Crowd Sales and not), we need to be able to distinguish between shares our campaign distributed and all other tokens. m_strCampaignName is used for this purpose, later we plan on adding some additional security here.

As long as a campaign is not finalized, ShareHolder contract will not treat the shares you distributed as regular shares, particularly, it will not be possible to sell them. If a campaign fails, same thing: shares will not be sellable. And only if you finalize a successful campaign, shares will become "bonus" ones.

Unlike "regular" shares that you can sell immediately, "bonus" shares are ones you never paid for. Therefore, in order to pay for them, you need to wait for its price to rise above the min. share price (defined in a ShareHolder contract). Then it can be sold.

An option has two extra fields. First, "Campaign Name", allows you to change the name of a campaign; second one specifies, how many tokens one should buy in order to get one share. It allows you to issue different amounts of stocks and shares.







Learn Touch Typing

(C) snowcron.com, all rights reserved

Please read the disclaimer