---
title: "Comment by Green Monster on \"The 2018 guide to writing (and testing) real world crowdsale contracts\" | Hashnode"
description: "First of all, thank you very much for this tutorial! As a beginner, I found it very educational and fairly straightforward to follow. However, there is somethin"
url: "https://hashnode.com/posts/the-2018-guide-to-writing-and-testing-real-world-crowdsale-contracts/5a67bb65357c012503a334c9/comment/5a72a5da9cc7099e7dbf352c"
---

[Discussion](https://hashnode.com/posts/the-2018-guide-to-writing-and-testing-real-world-crowdsale-contracts/5a67bb65357c012503a334c9)

Comment [The 2018 guide to writing (and testing) real world crowdsale contracts](https://hashnode.com/posts/the-2018-guide-to-writing-and-testing-real-world-crowdsale-contracts/5a67bb65357c012503a334c9)

[Green Monster](https://hashnode.com/@GMCC)

[Feb 1, 2018](https://hashnode.com/posts/the-2018-guide-to-writing-and-testing-real-world-crowdsale-contracts/5a67bb65357c012503a334c9/comment/5a72a5da9cc7099e7dbf352c)

First of all, thank you very much for this tutorial! As a beginner, I found it very educational and fairly straightforward to follow. However, there is something that I am having trouble understanding.

Using the code provided, I am able to purchase 5HTs for 1ETH. Success!

This is utilizing "uint8 public decimals = 18;" in HashcodeToken.sol My understanding is that each HT is divisible up to 18 decimals.

From what I've read, setting uint8 "public decimals = 0; should create a token that is indivisible. However, deploying the contract with only this change creates far too many tokens!

So, it seems that in HashnodeCrowdsale.sol, the token distribution needs to be changed from: uint256 public maxTokens = 100000000000000000000;

to: uint256 public maxTokens = 100; for all token amounts in the contract. Is this a correct interpretation?

If so, I can't seem to work out is how the "rate" should change.

```
  if (stage == CrowdsaleStage.PreICO) {
    setCurrentRate(5);
  } else if (stage == CrowdsaleStage.ICO) {
    setCurrentRate(2);
```

Setting the rate to 0.1 for example returns an error and keeping the rate "as is" creates errors when running the TestCrowdsale. I've tried looking at the documentation but I can't seem to wrap my mind around it! How can I make this HashnodeToken indivisible and what effect does it have on the rate?

[Yan Kun](https://hashnode.com/@samyankun)

[Feb 4, 2018](https://hashnode.com/posts/the-2018-guide-to-writing-and-testing-real-world-crowdsale-contracts/5a67bb65357c012503a334c9/comment/5a72a5da9cc7099e7dbf352c#reply-5a7708eaf7ef75131419fb1f)

Can I set a time peroid to change PreICO to ICO, or are there some ways to set the rate mannually? Thanks

[Meshach Ishaya](https://hashnode.com/@Mishael)

[Mar 16, 2018](https://hashnode.com/posts/the-2018-guide-to-writing-and-testing-real-world-crowdsale-contracts/5a67bb65357c012503a334c9/comment/5a72a5da9cc7099e7dbf352c#reply-5aabf7f89e26ad202fd9aa9f)

I am getting this error when I run "truffle deploy/migrate"

Deploying HashnodeCrowdsale... ... 0x53ddcb6df7447ea1a73b23e0ca5059012c996e92871384289b5ba1aaec11f02f Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: The contract code couldn't be stored, please check your gas amount. at Object.callback (/usr/local/lib/node\_modules/truffle/build/webpack:/~/web3/lib/web3/contract.js:147:1) at /usr/local/lib/node\_modules/truffle/build/webpack:/~/web3/lib/web3/method.js:142:1 at /usr/local/lib/node\_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:89:1 at /usr/local/lib/node\_modules/truffle/build/webpack:/~/truffle-migrate/index.js:225:1 at /usr/local/lib/node\_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1 at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node\_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1) at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node\_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1) at XMLHttpRequest.\_setReadyState (/usr/local/lib/node\_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1) at XMLHttpRequest.\_onHttpResponseEnd (/usr/local/lib/node\_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1) at IncomingMessage.<anonymous> (/usr/local/lib/node\_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1) at IncomingMessage.emit (events.js:165:20) at endReadableNT (\_stream\_readable.js:1101:12) at process.\_tickCallback (internal/process/next\_tick.js:152:19)

It keeps failing on my machine..

P.S - I have checked my gas limit in truffle.js, increased it and checked for anything I could find pointing this error but none so far.

[Hodl Coin](https://hashnode.com/@HodlThatCoin)

[Mar 22, 2018](https://hashnode.com/posts/the-2018-guide-to-writing-and-testing-real-world-crowdsale-contracts/5a67bb65357c012503a334c9/comment/5a72a5da9cc7099e7dbf352c#reply-5ab399be88b5223f0ba26dfb)

Any luck with this? I have the same issue and can't figure out what's wrong.
