24
ICO_Documentation Documentation Release 0.0.1 Stefano Ballerini Aug 02, 2018

ICO Documentation Documentation

  • Upload
    others

  • View
    51

  • Download
    0

Embed Size (px)

Citation preview

Page 1: ICO Documentation Documentation

ICO_Documentation DocumentationRelease 0.0.1

Stefano Ballerini

Aug 02, 2018

Page 2: ICO Documentation Documentation
Page 3: ICO Documentation Documentation

Contents

1 Tools for writing and deploying smart contracts 1

2 External Documentation 3

3 Smart Contract Example 5

4 Deploying smart contract in Ethereum blockchain 7

5 Guide 9

i

Page 4: ICO Documentation Documentation

ii

Page 5: ICO Documentation Documentation

CHAPTER 1

Tools for writing and deploying smart contracts

Infura – scalable blockchain infrastructure. Don’t run a full Ethereum node, let them handle the infrastructure layer

Mist Browser – browse the dApp. Separate browser to browse dApps and interact with them.

Truffle Framework – The Ethereum Development framework. It has built-in smart contract compilation, linking,deployment, and binary management.

Metamask – It allows to run Ethereum dApps right in the browser without running a full Ethereum node. It is a browserplugin that allows users to make Ethereum transactions through regular websites.

Remix – Web IDE to write, deploy and run Solidity smart contracts

ETHFiddle - Share you Solidity Script

ETHFiddle - Framework to audit smart contract code

1

Page 6: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

2 Chapter 1. Tools for writing and deploying smart contracts

Page 7: ICO Documentation Documentation

CHAPTER 2

External Documentation

Solidity Documentation - Solidity Documentation

Create your own crypto - Create your own crypto (official)

ICO Smart Contact Framework - ICO Smart Contact Framework

3

Page 8: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

4 Chapter 2. External Documentation

Page 9: ICO Documentation Documentation

CHAPTER 3

Smart Contract Example

1 pragma solidity ^0.4.0;2

3 contract Coin {4 // The keyword "public" makes those variables5 // readable from outside.6 address public minter;7 mapping (address => uint) public balances;8

9 // Events allow light clients to react on10 // changes efficiently.11 event Sent(address from, address to, uint amount);12

13 // This is the constructor whose code is14 // run only when the contract is created.15 function Coin() {16 minter = msg.sender;17 }18

19 function mint(address receiver, uint amount) {20 if (msg.sender != minter) return;21 balances[receiver] += amount;22 }23

24 function send(address receiver, uint amount) {25 if (balances[msg.sender] < amount) return;26 balances[msg.sender] -= amount;27 balances[receiver] += amount;28 Sent(msg.sender, receiver, amount);29 }30 }

address public minter;

It’s a 160 bit variable ideal for storing addresses on the Ethereum network.

5

Page 10: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

mapping (address => uint) public balances;

Creates a mapping between address and unit type which stores the coin balance in each address

function Coin() {minter = msg.sender;}

Constructor function. Executed as soon as the contract is deployed. This sets the value of minter to the address whichhas deployed the contract. This ensures that only the owner of the contract can mint new coins and nobody else. Thisis ensured by the following function:

function mint(address receiver, uint amount)

Function sending coin value equal to amount to the receiver address.

function send(address receiver, uint amount)

Function sending coins to the receiver’s address from the sender’s address

6 Chapter 3. Smart Contract Example

Page 11: ICO Documentation Documentation

CHAPTER 4

Deploying smart contract in Ethereum blockchain

Testnets simulate the Ethereum network and EVM. It enables developers to upload and interact with smart contractswithout paying the cost of gas.

Smart contracts must pay gas for their computations on the Ethereum network. However, testnets provide environmentsfor developers to test their contracts without paying any money. Testnet gas is available for free from many publicareas. es. ropsten

7

Page 12: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

8 Chapter 4. Deploying smart contract in Ethereum blockchain

Page 13: ICO Documentation Documentation

CHAPTER 5

Guide

5.1 ICO

5.1.1 Open Points

• What is the total supply? Are we open to further Coin Offering trances? if so, how are these structured?

• What % of allocation is distributed in the private-sale in relation to the % sold in the crowdsale?

• Are tokens accessible immediately after transaction or only after the ICO end?

• What happens if the private-sale target is not reached?

• If the goal is not met, does the ICO continues until the payments reach the min cap?

• What is the ICO bonus scheme for early buyers?

• Are raised funds returned if the goal is not met?

• What is the founders initial token supply?

• Allocation—What % are given to team, investors, partners, bounty, reserving for the ecosystem, reserving forthe company/foundation?

• Where will the money that you raise go to? have an annual budget for the next 5 years.

• Does a bouty program exists? if so, how is it structured?

• Are funds raised during the ICO released during some vesting periods or under particular circumstances?

• Is raised ether stored in the contract or transferred immediately to some wallet (the difference is in the gascosts, accessibility of the funds and the security if you choose to store them on some particular hardware ormultisignature wallet).

• Are we geo-fencing? (excluding specific countries from participating— both US and Chinese investors)

• are we allowing funds/institutional investors to invest or only individuals?

• Are we 100% sure the token is not a security? do we have a official legal due diligence from ICO advisor?

9

Page 14: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

• How are performded security audit on the smart contract?

5.1.2 Answers

• What is the purpose of the token?

1. To increase the exchange adoption and robustness, Infinity Trade Coin 8TC holders will have the pos-sibility to claim x% of the total platform trading commissions, just by holding 8TC in their accounts.The award is calculated daily, based on to the 8TC holdings in user’s account at 0:00 (UTC+1) andthen claimed by the users.

2. To increase the exchange adoption and robustness, Infinity Trade Coin 8TC holders will have thepossibility to obtain a x% discount on trading commissions, just by holding 8TC in their accounts.

• How much do we want to raise? min cap? max cap? Based on our need for future development the mini-mum amount to be raises is at least 3 million euro. Because of this, we set milestones during the ICO thatwill enable incremental features:

1. soft cap - C 3M App Market

2. mid cap - C 7M App Market, Music Market

3. Hard cap - C 15M App Market, Music Market, Sport Market

• Which currencies are we accepting for the ICO? (BTC, ETH, anything else?) BTC and ETH If so then wewill need some complexity in the smart contract such as btcrelay

• Will be the KYC available for the pre-registration process to the ICO? yes

• What do we need this money for? road map?

2017

Q2

– Product designs and execution plan

– System architecture consolidation

– Legal and compliance frameworks

Q3

– internal KYC and on-boarding

– Whitepaper

– ICO smart contracts deployment

Q4

– 10.18 Start ICO

– 11.18 end ICO

– in platform smart contracts

2018

Q1

– admission to beta program (trading platform)

– open subscription for traders

– open admission for app developers

10 Chapter 5. Guide

Page 15: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

Q2

– in platform smart contracts fully integrated

– Launch Exchange beta

– market app open

Q3

– End of Beta

– further development and weekly features releases

– Strategic partnerships

Q4

– “block” market for crypto

2019

Q1

– open admission for music

Q2

– market music open

5.1.3 Requirements

1. It’s Necessary to building a specific reservation contract for the pre-sale to reserve a specific amount of allocationfor each of the pre-sale buyers and being transparent about who participated and at what price.

2. Raised ether is going to be transferred to a specific wallet after each payment,

Communication

(website, slack, social, press, interviews, etc)

• Website

– Landing page for the crowdsale

– Whitepaper

– Team

– Advisors

– Previous investors

– Roadmap

– Token allocation

– Links to social accounts

– Translations

• Internal communication channel (Slack, Rocket Chat, Riot, etc)

– Need to have a main communication channel and the team needs to be active there.

– Full-time community manager to moderate the communication channel

5.1. ICO 11

Page 16: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

– Need to setup the channels properly and moderate heavily

• BitcoinTalk

– Create a bitcointalk announcement of the token.

• Reddit

– Own your own subreddit, brand it, and put in a few posts.

• Newsletter

– Setup a newsletter on your website.

• Blog

– Need to have a clean, updated blog ideally with a history of posts already.

• Twitter

– have a clean updated Twitter account.

• Advertising

– In general, the teams that advertise look weaker.

• Public relations

– Press—Getting into both crypto publications + general news.

– Interviews—Q&A, speaking engagements, tech talks, etc.

– Events—Conferences, meetups, technical talks, dinners, online Q&A sessions, etc.

– Podcasts—Epicenter, Unchained, Ether Review, etc.

• Bouties

– Use bounty0x for bouties

• Community Management

– Need to have extra people on staff ready to answer questions. On all channels, all of the time.

5.1.4 Summary

Property ValueTicker 8TCToken ERC20Value 1 8TC = xCAccepted currency ETH, BTCTotal Supply 200.000.000 8TCSoft cap $ 1MHard cap $ 8M

Bonus discount program

Property ValuePrivate Sale 4M750K 40% discount2M 30% discount1.25M 20% discount

12 Chapter 5. Guide

Page 17: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

5.2 Solidity

5.2.1 Basic Example

A contract in the sense of Solidity is a collection of code (its functions) and data (its state) that resides at a specificaddress on the Ethereum blockchain.

1 pragma solidity ^0.4.0;2

3 contract SimpleStorage {4 uint storedData;5

6 function set(uint x) public {7 storedData = x;8 }9

10 function get() public view returns (uint) {11 return storedData;12 }13 }

Just store and retrieve information (a variable) on the blockchain.

1 pragma solidity ^0.4.0;

Ensures that the contract does not suddenly behave differently with a new compiler version.

5.2.2 Subcurrency Example

1 pragma solidity >0.4.24;2

3 contract Coin {4 // The keyword "public" makes those variables5 // readable from outside.6 address public minter;7 mapping (address => uint) public balances;8

9 // Events allow light clients to react to10 // changes efficiently.11 event Sent(address from, address to, uint amount);12

13 // This is the constructor whose code is14 // run only when the contract is created.15 constructor() public {16 minter = msg.sender;17 }18

19 function mint(address receiver, uint amount) public {20 if (msg.sender != minter) return;21 balances[receiver] += amount;22 }23

24 function send(address receiver, uint amount) public {25 if (balances[msg.sender] < amount) return;26 balances[msg.sender] -= amount;

(continues on next page)

5.2. Solidity 13

Page 18: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

(continued from previous page)

27 balances[receiver] += amount;28 emit Sent(msg.sender, receiver, amount);29 }30 }

The line event Sent(address from, address to, uint amount); declares a so-called “event” whichis emitted in the last line of the function send. User interfaces (as well as server applications of course) can listen forthose events being emitted on the blockchain without much cost. As soon as it is emitted, the listener will also receivethe arguments from, to and amount, which makes it easy to track transactions

In order to listen for this event, you would use

1 Coin.Sent().watch({}, '', function(error, result) {2 if (!error) {3 console.log("Coin transfer: " + result.args.amount +4 " coins were sent from " + result.args.from +5 " to " + result.args.to + ".");6 console.log("Balances now:\n" +7 "Sender: " + Coin.balances.call(result.args.from) +8 "Receiver: " + Coin.balances.call(result.args.to));9 }

10 })

5.3 Cryptocurrency Scuffold

5.3.1 Code example

1 pragma solidity ^0.4.16;2

3 interface tokenRecipient { function receiveApproval(address _from, uint256 _→˓value, address _token, bytes _extraData) external; }

4

5 contract TokenERC20 {6 string public name;7 string public symbol;8 uint8 public decimals = 18;9 uint256 public totalSupply;

10

11 // This creates an array with all balances12 mapping (address => uint256) public balanceOf;13 mapping (address => mapping (address => uint256)) public allowance;14

15 // This generates a public event on the blockchain that will notify clients16 event Transfer(address indexed from, address indexed to, uint256 value);17

18 // This generates a public event on the blockchain that will notify clients19 event Approval(address indexed _owner, address indexed _spender, uint256 _

→˓value);20

21 // This notifies clients about the amount burnt22 event Burn(address indexed from, uint256 value);23

24 /**(continues on next page)

14 Chapter 5. Guide

Page 19: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

(continued from previous page)

25 * Constructor function26 *27 * Initializes contract with initial supply tokens to the creator of the

→˓contract28 */29 function TokenERC20(30 uint256 initialSupply,31 string tokenName,32 string tokenSymbol33 ) public {34 totalSupply = initialSupply * 10 ** uint256(decimals); // Update total

→˓supply with the decimal amount35 balanceOf[msg.sender] = totalSupply; // Give the creator

→˓all initial tokens36 name = tokenName; // Set the name for

→˓display purposes37 symbol = tokenSymbol; // Set the symbol

→˓for display purposes38 }39

40 /**41 * Internal transfer, only can be called by this contract42 */43 function _transfer(address _from, address _to, uint _value) internal {44 require(_to != 0x0);

→˓ // Prevent transfer to 0x0 address. Use burn() instead45 require(balanceOf[_from] >= _value);

→˓ // Check if the sender has enough46 require(balanceOf[_to] + _value >= balanceOf[_to]); /

→˓/ Check for overflows47 uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Save this

→˓for an assertion in the future48 balanceOf[_from] -= _value;

→˓ // Subtract from the sender49 balanceOf[_to] += _value;

→˓ // Add the same to the recipient50 emit Transfer(_from, _to, _value);

→˓ // Asserts are used to use static analysis to find bugs in your code.→˓ They should never fail

51 assert(balanceOf[_from] + balanceOf[_to] == previousBalances);52 }53

54 /**55 * Transfer tokens56 *57 * Send `_value` tokens to `_to` from your account58 *59 * @param _to The address of the recipient60 * @param _value the amount to send61 */62 function transfer(address _to, uint256 _value) public returns (bool success)

→˓{63 _transfer(msg.sender, _to, _value);64 return true;65 }66

67 /**(continues on next page)

5.3. Cryptocurrency Scuffold 15

Page 20: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

(continued from previous page)

68 * Transfer tokens from other address69 *70 * Send `_value` tokens to `_to` on behalf of `_from`71 *72 * @param _from The address of the sender73 * @param _to The address of the recipient74 * @param _value the amount to send75 */76 function transferFrom(address _from, address _to, uint256 _value) public

→˓returns (bool success) {77 require(_value <= allowance[_from][msg.sender]); // Check allowance78 allowance[_from][msg.sender] -= _value;79 _transfer(_from, _to, _value);80 return true;81 }82

83 /**84 * Set allowance for other address85 *86 * Allows `_spender` to spend no more than `_value` tokens on your behalf87 *88 * @param _spender The address authorized to spend89 * @param _value the max amount they can spend90 */91 function approve(address _spender, uint256 _value) public92 returns (bool success) {93 allowance[msg.sender][_spender] = _value;94 emit Approval(msg.sender, _spender, _value);95 return true;96 }97

98 /**99 * Set allowance for other address and notify

100 *101 * Allows `_spender` to spend no more than `_value` tokens on your behalf,

→˓and then ping the contract about it102 *103 * @param _spender The address authorized to spend104 * @param _value the max amount they can spend105 * @param _extraData some extra information to send to the approved contract106 */107 function approveAndCall(address _spender, uint256 _value, bytes _extraData)108 public109 returns (bool success) {110 tokenRecipient spender = tokenRecipient(_spender);111 if (approve(_spender, _value)) {112 spender.receiveApproval(msg.sender, _value, this, _extraData);113 return true;114 }115 }116

117 /**118 * Destroy tokens119 *120 * Remove `_value` tokens from the system irreversibly121 *122 * @param _value the amount of money to burn

(continues on next page)

16 Chapter 5. Guide

Page 21: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

(continued from previous page)

123 */124 function burn(uint256 _value) public returns (bool success) {125 require(balanceOf[msg.sender] >= _value); // Check if the sender has

→˓enough126 balanceOf[msg.sender] -= _value; // Subtract from the sender127 totalSupply -= _value; // Updates totalSupply128 emit Burn(msg.sender, _value);129 return true;130 }131

132 /**133 * Destroy tokens from other account134 *135 * Remove `_value` tokens from the system irreversibly on behalf of `_from`.136 *137 * @param _from the address of the sender138 * @param _value the amount of money to burn139 */140 function burnFrom(address _from, uint256 _value) public returns (bool

→˓success) {141 require(balanceOf[_from] >= _value); // Check if the

→˓targeted balance is enough142 require(_value <= allowance[_from][msg.sender]); // Check allowance143 balanceOf[_from] -= _value; // Subtract from the

→˓targeted balance144 allowance[_from][msg.sender] -= _value; // Subtract from the

→˓sender's allowance145 totalSupply -= _value; // Update totalSupply146 emit Burn(_from, _value);147 return true;148 }149 }

function MyToken has to have the same name as the contract MyToken. This is a special, startup function that runsonly once and once only when the contract is first uploaded to the network

Transfer function

1 function transfer(address _to, uint256 _value) public {2 /* Check if sender has balance and for overflows */3 require(balanceOf[msg.sender] >= _value && balanceOf[_to] + _value >= balanceOf[_

→˓to]);4

5 /* Add and subtract new balances */6 balanceOf[msg.sender] -= _value;7 balanceOf[_to] += _value;8 }

To stop a contract execution mid-execution you can either return or throw The former will cost less gas but it can bemore headache as any changes you did to the contract so far will be kept. In the other hand, ‘throw’ will cancel allcontract execution, revert any changes that transaction could have made and the sender will lose all Ether he sent forgas. But since the Wallet can detect that a contract will throw, it always shows an alert, therefore preventing any Etherto be spent at all.

5.3. Cryptocurrency Scuffold 17

Page 22: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

Internal functions

1 /* Internal transfer, can only be called by this contract */2 function _transfer(address _from, address _to, uint _value) internal {3 require (_to != 0x0); // Prevent transfer to 0x0

→˓address. Use burn() instead4 require (balanceOf[_from] >= _value); // Check if the sender has

→˓enough5 require (balanceOf[_to] + _value >= balanceOf[_to]); // Check for overflows6 require(!frozenAccount[_from]); // Check if sender is frozen7 require(!frozenAccount[_to]); // Check if recipient is

→˓frozen8 balanceOf[_from] -= _value; // Subtract from the sender9 balanceOf[_to] += _value; // Add the same to the

→˓recipient10 emit Transfer(_from, _to, _value);11 }

Now all your functions that result in the transfer of coins, can do their own checks and then call transfer with thecorrect parameters. Notice that this function will move coins from any account to any other, without requiring anyone’spermission to do so: that’s why it’s an internal function, only called by the contract: if you add any function calling it,make sure it properly verifies if the caller should be have permission to move those.

Contract Administrator

Inheritance allows a contract to acquire properties of a parent contract, without having to redefine all of them. Thismakes the code cleaner and easier to reuse

1 contract owned {2 address public owner;3

4 function owned() {5 owner = msg.sender;6 }7

8 modifier onlyOwner {9 require(msg.sender == owner);

10 _;11 }12

13 function transferOwnership(address newOwner) onlyOwner {14 owner = newOwner;15 }16 }

This creates a very basic contract that doesn’t do anything except define some generic functions about a contract thatcan be “owned”. Now the next step is just to add the text is owned to the contract:

1 contract MyToken is owned {2 /* the rest of the contract as usual */

18 Chapter 5. Guide

Page 23: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

5.4 Test Net (Ropsten Network)

5.4.1 To start

We need 3 components:

• Ethereum Address (Ropsten Network)

• Some Ether (Ropsten Network)

• Solidity contract

Ethereum address

Go to MyEtherWallet (MEW) and create an account.

To get setup, click the right hand side corner, change the network to Ropsten (MyEtherWallet) → click the New Wallet→Enter a password you can remember → Download / Save your Keystore file in a safe space → Save your PrivateKey in a safe space.

To view your wallet address, go to →View Wallet Info →Private Key → Enter the saved private key →Unlock yourWallet

Ether

As an example we will use the Ropsten Test network. But there are other testnet that can be used. To get some RopstenEthereum Just access this faucet and put your ropsten address.

Solidity contract

As contract we can use the contract defined in scuffold page.

5.4.2 Deploy

• Go to Remix

• In the browser/ballot.sol, paste the code you just edited! If something red comes up, there is something wrongin the code.

• Now Under Compile →Details →Choose the Token you are creating

• Under ByteCode press the button to copy the ByteCode to your clipboard —( Into this section, what mayappear are different things on the ByteCode. What you have to copy is the “object” ByteCode, adding a 0x inthe beginning. So you will have 0xByteCode.)

• Go to MEW

• Navigate to the Contracts tab → Press Deploy Contract

• Paste your ByteCode into the ByteCode box. Your gas limit should automatically update

• Access your wallet by going into the Private Key → Enter your private key →Unlock your wallet

• Now press Sign Transaction →Deploy Transaction

• Click on the transaction tx or access etherscan to check if the contract went through.

5.4. Test Net (Ropsten Network) 19

Page 24: ICO Documentation Documentation

ICO_Documentation Documentation, Release 0.0.1

Register the contract

• In the Overview Tab → Click on the Contract Address

• Go to the Contract Code Tab → Click Verify and Publish

Get it right once or get it wrong forever.

1. Be sure that the contract address field corresponds to the contract address that you have just deployed. Remembercontract address is different to the MEW address you created so make sure not to get them confused

2. The contract name has to match the one in the code

3. To check which version of the complier, go back to the remix page where you got the BYTECODE from andlook at the URL, the complier version will be there. In most cases it should be: v0.4.19+commit.c4cbbb05.js

4. On Optimisation, choose No (We haven’t enable it before)

5. On ENTER THE SOLIDITY CONTRACT CODE BELOW, copy the whole code from Remix, and paste in thatarea. NOT THE BYTECODE, but the code itself.

6. Now, leave the other fields in blank and click on Verify and Publish.

20 Chapter 5. Guide