a

How to Deploy a Crowdsale Initial Coin Offering (ICO) to your own Private Testnet

We’ve been trying to deploy a Crowdsale Initial Coin Offering (ICO) Solidity contract to the Ethereum block chain for the better part of 2 months. We’ve looked into the Open Zeppelins tutorials on How to Create Token an Initial Coin Offering using Truffle and Open Zeppelin. We were able to compile their Crowdsale ICO, but […]

We’ve been trying to deploy a Crowdsale Initial Coin Offering (ICO) Solidity contract to the Ethereum block chain for the better part of 2 months.

Code for an Initial Coin Offering Fund raise
Code for an Initial Coin Offering Fund raise


We’ve looked into the Open Zeppelins tutorials on How to Create Token an Initial Coin Offering using Truffle and Open Zeppelin. We were able to compile their Crowdsale ICO, but each time I went to perform ‘truffle migrate’, I encountered the dreaded “Out of Gas” error message that is the default error provided by Truffle’s migration code. This error tells you nothing. After a while you start to deduce that nothing is wrong with your TestRPC or private testnet config, instead not all of the code has been checked into Github…
With the Open Zeppelin tutorial, the deploy step is not specified. With many of the other ICO open source codebases in Github, the deploy step is not specified either. The deploy step of Truffle is arguably the most poorly documented portion of their project. The Truffle documentation provides you with a few sentences. Without an example on how to deploy, forget it.


That’s where AllCode comes in. We’ve checked in a version of a Crowdsale ICO that you can actually compile, deploy, execute, and even run unit tests on. You can find it here
http://github.com/MobileAWS/allcode-coin


In order to get this running on your local machine, you’ll need to take the following steps. Our advice is to install geth locally and configure your own private testnet using a custom genesis block, click here to learn how. The Open Zeppelin tutorial says that you can use TestRPC. I’d avoid TestRPC. When I use TestRPC, I start to get weird invalid opscode errors, which if you google around, point to issues with TestRPC. Our advice is to figure out how to build your own private testnet with a custom genesis block.
When working with Ethereum locally, I usually have four terminal shells open. This may seem excessive, but it’s not
The first terminal shell executes geth on your own private testnet locally

geth --networkid 200 --identity node1 --verbosity 3 --datadir=~/myBlockChain/node1
--rpc --rpcapi 'web3,eth,net,debug' --rpcaddr "127.0.0.1" --rpcport "8545" --rpccorsdomain "*"

The second terminal shell is used to communicate with geth via ipc. Why do I need to communicate with geth via ipc? The documentation is not the greatest here, but what I’ve discovered is that in order to write to the blockchain, you have to be 1) mining with an account and 2) the account that you are mining under should be unlocked. If your account is not mining nor unlocked, then you will start to encounter hangs and frustrating error messages.
Use the following for ipc,

geth attach /Users/joelgarcia/myBlockChain/node1/geth.ipc

To start mining, you’d type the following in the ipc terminal prompt

miner.setEtherbase ( personal.listAccounts[/fusion_builder_column][fusion_builder_column type="1_1" background_position="left top" background_color="" border_size="" border_color="" border_style="solid" spacing="yes" background_image="" background_repeat="no-repeat" padding="" margin_top="0px" margin_bottom="0px" class="" id="" animation_type="" animation_speed="0.3" animation_direction="left" hide_on_mobile="no" center_content="no" min_height="none"][0] )
miner.start()

To unlock your account, you’d type the following in the ipc terminal prompt

personal.unlockAccount( personal.listAccounts[0] )

Now, in your third terminal window, you’d install Truffle and clone from the github repo. Next, you’d run the following in the root directory of your git clone.

truffle compile

Truffle compile will build the json files that are required to deploy the Solidity contracts to the block chain. The Truffle.js in the root directory will specify that you’re talking to localhost on 8545.
In the fourth terminal window, you’ll want to open up the file: /allcode-coin/migrations/2_deploy_contracts.js with vi. You’ll need to edit this file. You’ll need to have created 2 accounts via the ipc command personal.newAccount(). From those 2 accounts, you’ll want to include one of those addresses as the wallet and the other as the owner. Navigate down to the deploy code. Notice that the deploy code is populated. We’ll go through the deploy code, and the unit tests in our next blog post
Now return back to the third terminal window, and type

truffle migrate

Truffle migrate will actually attempt to deploy to your local testnet. Believe it or not. Your crowdsale Initial Coin Offering (ICO) is now deployed to your test network. This should theoretically work on your private testnet. If it doesn’t, please reach out, [email protected].

How to deploy a crowdsale initial coin offering to the Ethereum block chain
How to deploy a crowdsale ico to the Ethereum block chain

Related Articles

3 Ways Gen AI and AWS can Enhance Your Business

3 Ways Gen AI and AWS can Enhance Your Business

Amazon is on the cutting edge of new technologies. They have been increasingly experimenting with AI and learning algorithms, culminating in their most recent breakthroughs in Generative AI. Developers and technology enthusiasts have access to their innovations through the tools available on AWS.

Business Owner’s Guide to DevOps Essentials

Business Owner’s Guide to DevOps Essentials

As a business owner, it’s essential to maximize workplace efficiency. DevOps is a methodology that unites various departments to achieve business goals swiftly. Maintaining a DevOps loop is essential for the health and upkeep of deployed applications.

AWS Graviton and Arm-architecture Processors

AWS Graviton and Arm-architecture Processors

AWS launched its new batch of Arm-based processors in 2018 with AWS Graviton. It is a series of server processors designed for Amazon EC2 virtual machines. The EC2 AI instances support web servers, caching fleets, distributed data centers, and containerized microservices. Arm architecture is gradually being rolled out to handle enterprise-grade utilities at scale. Graviton instances are popular for handling intense workloads in the cloud.