Do you want to understand how to write smart contracts but have very limited
technical knowledge? Do you want to understand how to write smart
contracts to issue tokens for your ICO? Look no further. Here is a complete
guide on how to go about it.
Summary
What is an ICO
https://howtotoken.com/ico/how-to-write-a-smart-contract-for-your-ico-an-ultimate-guide/ 1/12
3/25/2018 How To Write A Smart-Contract For Your ICO? An Ultimate guide - The Ultimate Crypto How-to Guides
ICO, or Initial coin offerings, is the new craze now. Blockchain technology provides a unique way
for incentivizing early adopters to participate in a project and garner initial funding by issuing
“tokens”. One needn’t get scared by the new terms which are used in this domain. Below is a
comprehensive guide on what an ICO is, and how someone can learn more about “contracts”
which power these ICOs. So let’s dive right in!
These tokens can be obtained by buying them in an exchange for fiat currencies like USD, or they
can be earned by performing specific services on the network (like mining). The beauty of these
tokens lie in the fact that their price also appreciates and depreciates based on the demand for
these tokens. This behavior is similar to shares in companies, which reflect partial ownership of the
company. Tokens reflect both the currency used to pay for services in the network and also as
equity in the network of that token.
https://howtotoken.com/ico/how-to-write-a-smart-contract-for-your-ico-an-ultimate-guide/ 2/12
3/25/2018 How To Write A Smart-Contract For Your ICO? An Ultimate guide - The Ultimate Crypto How-to Guides
As the network effect of that token increases, the token appreciates in pricing. The first step in
determining whether tokens make sense for your project or not depends upon what your project’s
objective is and is there a way that it can be “tokenised.” As discussed above, tokens are not just
the currency used in the network, but they are a unit of the business model on which the network is
built on.
1. There should be a utility value to the token in the network. The token of the Ethereum platform,
for instance, is Ether, and it is used as currency for paying transaction fees for any computation
performed in the Ethereum blockchain.
2. There should be crypto-economic incentives for players to buy tokens, and the token issuance
mechanism should be designed in such a way that their value should increase as the usage of
the token increases. For example, Filecoin is the token for IPFS which is used for storing files in
distributed hard drive networks. As more users want to store files in a distributed way, they
would need file coin tokens. Generally, these crypto tokens define beforehand how the token
supply will evolve over time. These policies are designed in such a way where the value of the
token increases as the services provided by the network are used more.
ERC20 is a token standard which makes it very easy to issue new crypto tokens. It is based on
Ethereum and describes the functions and events that an Ethereum token contract has to
implement. But before we go ahead and learn how one can issue tokens for their project, we must
understand what a “smart contract” is. This is the main topic for this post after all.
https://howtotoken.com/ico/how-to-write-a-smart-contract-for-your-ico-an-ultimate-guide/ 3/12
3/25/2018 How To Write A Smart-Contract For Your ICO? An Ultimate guide - The Ultimate Crypto How-to Guides
Traditionally, we are used to applications which are hosted by a centralized organization. While the
code of the application may be distributed across multiple physical servers, they are controlled by
a single entity. For example, Facebook is a centralized app which is controlled by an entity called
Facebook Inc. Decentralised apps, on the other hand, are not controlled by a central entity but are
governed by code and the protocols set within them. These codes are generally open sourced and
anybody can use them to create a new dApp of their own. Some Ethereum-based dApps that have
been successful are Golem, Augur, and Melonport. These dApps have been able to achieve
millions in market cap.
1. Script in Bitcoin – Script has limited capabilities when processing documents. Bitcoin features
a non-Turing complete scripting language, which allows for specifying under which conditions a
transaction can be redeemed. The scripting language is quite limited, as it only features some
basic arithmetic, logical, and crypto operations (e.g. hashing and verification of digital
signatures).
2. Automated Transactions is another Turing complete smart contract language, used in
cryptocurrencies like Burstcoin and Qora. An example of its usage is atomic cross-chain trading.
Atomic cross-chain trading enables two parties, who own coins in different cryptocurrencies, to
exchange them without need for a third, trusted party.
3. NXT: NXT is a public blockchain platform that contains a limited selection of templates for smart
contracts. You have to use what is given, you can’t write your own code.
4. Chain – Chain provides enterprise-grade blockchain infrastructure with SDKs in Java, Ruby,
and NodeJS.
Advantages Disadvantages
https://howtotoken.com/ico/how-to-write-a-smart-contract-for-your-ico-an-ultimate-guide/ 4/12
3/25/2018 How To Write A Smart-Contract For Your ICO? An Ultimate guide - The Ultimate Crypto How-to Guides
Simple and easy with common use Only contains limited templates. Can’t
NXT
cases provided in templates. develop contracts as you wish.
1. Smart contracts should not be making calls to external web services, APIs, or external
databases. This can lead to multiple independent executions of the same smart contract code
having different results. This could break the consensus of the blockchain. Oracles, which
update data from the real world to the blockchain, are a way to solve this problem.
2. Smart contracts can only solve issues which can be objectively decided based upon the facts.
This constraint makes smart contracts less valuable for legal contracts, where a dispute arises
when there are no objective facts – but instead the subjective judgement of two parties.
3. The most important limitation for “smart contracts” is that (at present) it is used for simple
contract models based on the pattern “if a, then b” or similar variations. It will be difficult to
include more subjective considerations in the contract like “without undue delay” and “beyond a
reasonable doubt” which is common in our current legal parlance.
While these limitations currently exist, teams are working to make these smart contracts more
intelligent. With the advent of IoT, it’s easier to relay real-time, real world data which can be saved
on blockchains by oracles. Many blockchain oracle services, like Oraclize, have started up which
push real world data into blockchains. Even with simple “if-then” smart contracts, there are many
cases which are set to be disrupted by smart contracts.
https://howtotoken.com/ico/how-to-write-a-smart-contract-for-your-ico-an-ultimate-guide/ 5/12
3/25/2018 How To Write A Smart-Contract For Your ICO? An Ultimate guide - The Ultimate Crypto How-to Guides
3. Truffle Framework – Truffle is a popular development framework for Ethereum. It has built-in
smart contract compilation, linking, deployment, and binary management which greatly
simplifies the job of an Ethereum developer.
4. Metamask – MetaMask is a bridge that allows one to visit the distributed web of tomorrow in
their browser today. It allows users to run Ethereum dApps right in their browser without running
a full Ethereum node. It is a browser plugin that allows users to make Ethereum transactions
through regular websites. As of September, 2017, Metamask is available only as a plugin in a
Chrome browser.
5. Remix – Remix is a web browser based IDE that allows users to write Solidity smart contracts,
then deploy and run the smart contract.
Source: remix.ethereum.org
https://howtotoken.com/ico/how-to-write-a-smart-contract-for-your-ico-an-ultimate-guide/ 6/12
3/25/2018 How To Write A Smart-Contract For Your ICO? An Ultimate guide - The Ultimate Crypto How-to Guides
1. Viper – Viper focuses on security and language and compiler simplicity. It has a python-like
indentation scheme.
2. Lisk – Lasik uses javascript as a smart contract language.
3. Chain – Chain provides enterprise-grade blockchain infrastructure with SDKs in popular
languages such as Ruby, Java, and NodeJS.
contract Coin {
// The keyword "public" makes those variables
// readable from outside.
address public minter;
mapping (address => uint) public balances;
defines a public variable of type address which is publicly accessible. The address type is a 160 bit
variable ideal for storing addresses on the Ethereum network.
creates a mapping between address and unit type which stores the coin balance in each address.
You can think of it as a ledger that records where how many coins are at each address.
https://howtotoken.com/ico/how-to-write-a-smart-contract-for-your-ico-an-ultimate-guide/ 7/12
3/25/2018 How To Write A Smart-Contract For Your ICO? An Ultimate guide - The Ultimate Crypto How-to Guides
function Coin() {
minter = msg.sender;
}
this function is the constructor function which is executed as soon as the contract is deployed. This
sets the value of minter to the address which has deployed the contract. This ensures that only the
owner of the contract can mint new coins and nobody else. This is ensured by the following
function:
This function only gets executed if it is called by the minter. The function sends coin value equal to
amount to the receiver address. If it is called by someone other than the minter, then this function
does nothing.
This function sends an amount of coins to the receiver’s address from the address calling the
function. For example, if Bob calls this function with Alice’s address and the amount is 1000, then
1000 coins will be transferred from Bob’s account to Alice’s account.
The above smart contract shows how it can be used to mint coin and transfer it to a specific
address.
What is testnet?
Testnets simulate the Ethereum network and EVM. They enable developers to upload and interact
with smart contracts without paying the cost of gas.
Smart contracts must pay gas for their computations on the Ethereum network. If you want to run a
smart contract on Ethereum networks, you need to pay “gas” for the transaction to complete.
However, testnets provide environments for developers to test their contracts without paying any
money. Testnet gas is available for free from many public areas.
Etherscan is the block explorer for the Ethereum Blockchain. A block explorer is basically a search
engine that allows users to easily lookup, confirm, and validate transactions that have taken place
https://howtotoken.com/ico/how-to-write-a-smart-contract-for-your-ico-an-ultimate-guide/ 8/12
3/25/2018 How To Write A Smart-Contract For Your ICO? An Ultimate guide - The Ultimate Crypto How-to Guides
on the Ethereum Blockchain. Smart contracts can be verified in etherscan by using this link
To get you started with smart contracts, you can check out the following templates below. The
Ethereum and solidity documentation have simple contracts to get you started. Once you have
implemented these, you can check out more advanced templates given by IBM. The IBM smart
contract templates show how you can use outputs from IoT devices to control smart contracts.
Ethereum dApp tutorial by Mahesh gives an example from start to finish on how to implement and
deploy a voting dApp on Ethereum.
The best way to learn about any domain is to talk to the experts in the field. Fortunately, the
blockchain community has a very open forum with folks willing to share their knowledge with new
members. You can check out the following channels to understand in more details what the
community is discussing. You can also ask your queries and the community is more than happy to
answer.
If you want to learn more about the general blockchain, Bitcoin’s slack channel is a good place to
hang out. For more specific details on Ethereum and smart contracts, check out the Ethereum and
solidity gitter channels. Coinfund is an active project where you can ask questions and follow what
people are discussing.
https://howtotoken.com/ico/how-to-write-a-smart-contract-for-your-ico-an-ultimate-guide/ 9/12
3/25/2018 How To Write A Smart-Contract For Your ICO? An Ultimate guide - The Ultimate Crypto How-to Guides
Facebook
Subscribe to our Newsletter
Add a comment...
ト ガリ · Works at Self-Employed
we are planning an ico for our company. we are looking for consultants or people who can help us on this. you can
contact us on viber or messenger 09498893252.Thankyou
Like · Reply · 2w
contract Coin {
// The keyword "public" makes those variables
// readable from outside.
address public minter;
mapping (address =>uint256) public balances;... See More
Like · Reply · 7w
Related
https://howtotoken.com/ico/how-to-write-a-smart-contract-for-your-ico-an-ultimate-guide/ 10/12
3/25/2018 How To Write A Smart-Contract For Your ICO? An Ultimate guide - The Ultimate Crypto How-to Guides
How To: Judge If The Token How To: Judge If The ICO Will How to Set Up In-Game
Will Rise In Value After ICO Deliver The Product Monetization Using a
Blockchain Platform
Blockchain Developer Salaries How To Properly Use Your What You Need to Learn
– 2018 Report Knowledge From Developer When Building a Successful
Courses To Launch Your Blockchain Developer Career
Project
Howtotoken
https://howtotoken.com/ico/how-to-write-a-smart-contract-for-your-ico-an-ultimate-guide/ 11/12
3/25/2018 How To Write A Smart-Contract For Your ICO? An Ultimate guide - The Ultimate Crypto How-to Guides
Community Program
https://howtotoken.com/ico/how-to-write-a-smart-contract-for-your-ico-an-ultimate-guide/ 12/12