Professional Documents
Culture Documents
- Shlomi Zeltsinger
S H LO M I Z E LT S I N G E R
Blockchain Made Simple
(http://zeltsinger.com/)
O ering shares in the form of coins is a great way for raising funds and for potential investors to invest in many of the new and exiting new projects out there. But here’s something
most don’t know: Most ICOs are nothing more than copy-past of the same code that was used in a dozen of previous ICOs – AND RIGHTFULLY SO.
The reason the same code is used again and again (with moderate variations) lies at the fact that this code was developed and tested by professionals, and it provides many useful
features both to the creators of 3rd party apps (like wallets and exchanges) but also to the end users, who can be somewhat assured that the tokens they’ve just bought can be
used and exchanged with relative ease.
Also, many of these generic contracts sometimes issue coins in a rate that has very little economic reason behind it (what does it mean to get 57PZC? Is that mean that each coin
will be equal one pizza in the future? Will the price of future pizza will be determinate in a coin exchange? How do you calculate the cost of operating and maintaining a smart
contract that doesn’t exist yet?).
I have absolutely no doubt that many companies actually using the raised funds in a responsible manner. They’re working hard to deliver a real final product, and I’m sure that
there’re also many investors who understand that these ICOs tokens are usually nothing more than a financial assets (at least at this early stage) and the fact that they’re issued
using a generic contract is not a surprise to them, but there are many others who don’t. And for them, I dedicate this post.
ERC20 Tokens
http://zeltsinger.com/2017/04/22/ico-simple-simple/ 1/6
1/22/2018 ICO - Simple. Too simple. - Shlomi Zeltsinger
While this standard isn’t fully accepted (and enforced), many token developers adhere to it as it provides them with many benefits, especially regarding interacting with other
Ethereum services.
The functions signature suppose to match the basic functionality that is expected from every token smart contract.
http://zeltsinger.com/2017/04/22/ico-simple-simple/ 2/6
1/22/2018 ICO - Simple. Too simple. - Shlomi Zeltsinger
Add the following parameters to your token contract:
function ShlomiCoin() {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY; // Give all of the initial tokens to the contract deployer.
}
And finally mash it all together to get your token contract. (Full code on Github) (https://github.com/Shultzi/Education/blob/master/ico/erc20.sol).
Pay attention, this is a standard ERC20 token, but it’s not supporting crowd-selling yet. However, making sure that your token is working and is on per with the latest standard is a
significant step on the way to create a stable ICO.
Under the Send tab, you can access your tokens and send them almost as if they were regular ethers
Get yourself a cup of co ee and get ready to o er your contract to the public.
The offering
Now that we know that we have a smart contract that works and is on per with modern standards, it’s time to o er it to the public.
http://zeltsinger.com/2017/04/22/ico-simple-simple/ 3/6
1/22/2018 ICO - Simple. Too simple. - Shlomi Zeltsinger
This step is slightly less rigid than the previous one as there’re many ways and parameters in which one ICO is di erent from the other. Some might place a cap on the sale; some
might have a time limit on the coin o ering or have a di erent price for each step of the sell, some might send the etheres directly to the company issuing the ICO while others
might split the ethers or freeze them or even destroy them. Sometimes the buyer might get the token immediately and sometimes only a er a certain time passed – You get the
picture. While ERC20 attempts to provide a uniform token standard, ICOs are the wild west.
1. Make sure that the transaction value isn’t empty (the buyer added ethers to the transaction).
2. Calculate the amounts of tokens to be issued ( price * amount ).
3. Update the new totalSupply variable with the new amount that was recently created.
4. Adds the new tokens into the buyer ( msg.sender ) balance.
5. Send the ethers to the owner of the ICO contract.
function () payable {
createTokens(msg.sender);
}
if (!owner.send(msg.value)) {
throw;
}
}
This function will be called automatically when ever someone sends money to the ICO contract by using the fallback function ( function () ).
Step two – Create a modi er to prevents buyers from sending ethers after the offering period ended.
modifier during_offering_time(){
if (now >= endTime){
throw;
}else{
_;
}
}
Step three – add time limit, owner address and price to your token constructor
function ShlomiICO() {
totalSupply = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY; // Give all of the initial tokens to the contract deployer.
endTime = now + 1 weeks;
owner = msg.sender;
}
And finally mash it all together to get your token contract. (Full code on Github). (https://github.com/Shultzi/Education/blob/master/ico/ico.sol)
You can now launch your ICO token and interact with it using mist (or any other compatible wallet). This token will work just like any other ERC20 token with one exception if
during the time of o ering someone will send it one ether, which senders will receive 500 tokens into their account, while the owner of the ICO contract will get that one ether into
his/hers ether account.
However, the code presented here is the real thing, it’s not the best example, but that’s the sca olding on which most ICOs are based upon. Usually, there’s no actual mechanism
that will incorporate these coins into a working application/smart contract – at least not at the time of ICO.
Share this:
(http://zeltsinger.com/2017/04/22/ico-simple-simple/?share=twitter&nb=1) (http://zeltsinger.com/2017/04/22/ico-simple-simple/?share=facebook&nb=1)
18
(http://zeltsinger.com/2017/04/22/ico-simple-simple/?share=google-plus-1&nb=1)
Related
(http://zeltsinger.com/2017/06/17/blockchain-developer-
The blockchain developer path - Blockchain at
path-blockchain-berkeley/)
Berkeley
(http://zeltsinger.com/2017/06/17/blockchain-
developer-path-blockchain-berkeley/)
Mapping the blockchain education ecosystem When I
created my first tutorials almost two years ago, there
were very few educational resources about
blockchains. The ecosystem was sorely lacking in
good courses, tutorials and guides to ease the
June 17, 2017
(http://zeltsinger.com/2017/04/14/the-ethereum- (http://zeltsinger.com/2017/04/09/blockchain-course-
In "The blockchain developer path"
signature-validation-app/) working-environment/)
Ethereum signature validation app Mixing environments - Creating working environment
(http://zeltsinger.com/2017/04/14/the-ethereum- for blockchain developers
signature-validation-app/) (http://zeltsinger.com/2017/04/09/blockchain-
April 14, 2017 course-working-environment/)
In "dApp" April 9, 2017
In "Bitcoin"
http://zeltsinger.com/2017/04/22/ico-simple-simple/ 5/6
1/22/2018 ICO - Simple. Too simple. - Shlomi Zeltsinger
http://zeltsinger.com/2017/04/22/ico-simple-simple/ 6/6