2021 Fillmore Street #1128

}

24/7 solutions

Top 10 Cloud Providers

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
Joel Garcia
Joel Garcia

Joel Garcia has been building AllCode since 2015. He’s an innovative, hands-on executive with a proven record of designing, developing, and operating Software-as-a-Service (SaaS), mobile, and desktop solutions. Joel has expertise in HealthTech, VoIP, and cloud-based solutions. Joel has experience scaling multiple start-ups for successful exits to IMS Health and Golden Gate Capital, as well as working at mature, industry-leading software companies. He’s held executive engineering positions in San Francisco at TidalWave, LittleCast, Self Health Network, LiveVox acquired by Golden Gate Capital, and Med-Vantage acquired by IMS Health.

Related Articles

What is Tigera?

What is Tigera?

An AWS Advanced Technology Partner, Tigera delivers Calico and Calico Enterprise for security and networking on EKS, both of which are AWS Containers Competency certified.

Vezt

Vezt

Blockchain technology has the potential to be a windfall for musicians, filmmakers, and video game developers. With the advent of new technology, the way we consume entertainment is changing. Vezt assists artists in distributing their tracks on digital channels and in promoting their work.

Top Platforms for NFTs: Polygon and Flow

Top Platforms for NFTs: Polygon and Flow

As blockchain technology continues to develop, we are seeing an increase in the number of platforms, languages, and applications. Your works of art and collectables can now be presented and traded in the form of non-fungible tokens (NFTs), which are a relatively new development.

Free AWS Services List

Download this FREE list of all 200+ AWS services and ensure that you're using the optimal services for your use case to enhance efficiency and save money!

Free AWS Business Continuity Plan Template

Make sure you have the proper business continuity plan explicitly for you AWS infrastructure. our professionals built this template using AWS best practices so you can ensure it's built to scale! 

Free Cloud Migration Checklist

Without the proper cloud migration strategy, you risk losing time and money. Ensure that your migration process is running smoothly with our FREE cloud migration checklist.

Free AWS Services List

You might be optimizing with the wrong AWS services. Download this FREE list of all 200+ AWS services and ensure that you're using the optimal services for your use case to enhance efficiency and save money!

Download your FREE AWS Business Continuity Plan Template
Download Free 200+ AWS Services Checklist
Download our 10-Step Cloud Migration ChecklistYou'll get direct access to our full-length guide on Google Docs. From here, you will be able to make a copy, download the content, and share it with your team.