What is an ICO?

During an ICO on Ethereum, participants send ether to a special smart contract, and, in return, receive tokens of equal value, depending on the price of the token set at the start of the sale.

In Ethereum, a token is just a balance  itself just a number  stored in a smart contract and associated with an owner's wallet address. A minimal implementation of a token would therefore only require a way to store how many tokens a given address owns. In Solidity, this can be achieved simply by using a mapping:

mapping (address => uint256) balances;

It's important to note that a token isn't something that resides in a user's wallet, nor is it something that can be moved around. When a user sees a token in their wallet, the wallet software is really making a call into the token contract and reading the balance associated with its address. Likewise, when a wallet sends a token to another address, the wallet is really calling into the contract to change the balances associated with the to and from addresses.

In addition to the contract that defines the new token, an ICO also requires a contract to define the terms of the sale itself. This contract only needs to exist while the sale is ongoing, and is used to receive ether in exchange for the tokens and to define variables such as the length of the sale and the price of the new tokens.

Finally, while it should be possible to interact with the ICO contracts directly, projects running an ICO almost always create a more user-friendly interface in the form of a web page.

In light of this, in this chapter, we will cover the following topics:

  • Project setup.
  • Token contracts (together with our implementation).
  • Token sale contracts.
  • Implementing our token sale contract.
  • Contract security.
  • Testing the code.
  • Deploying to a test network.
  • Verifying our contract on Etherscan.
  • Creating a frontend website.

At the end of the chapter we will summarize what we have done, and look briefly at suggestions for future work.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset