Deploying a Contract to the Ethereum Network on Morpheus Labs BPaaS

Morpheus Labs Team
Jun 3 · 4 min read
Image for post
Image for post

Decentralized Lottery (Part 3)

In our previous articles, we showed how a developer could build and test a smart contract on our BPaaS.

Now that our contract code has been built and tested, it is time to deploy it to a live Ethereum network. There are some configurations steps we must do on our project to set it up for a deployment to the blockchain protocol.

Generating an Ethereum Mnemonic list

We can deploy our contract to a local or an external network. The external network can be a test network like Ropsten or Rinkeby, or it can be the main Ethereum network.

In this example, we will deploy our contract to the Ropsten Ethereum network.

First, we need to create a set of mnemonics or a 12 word-set that maps to an Ethereum private key, and we can use it for our deployment.

To do so, go to https://iancoleman.io/bip39/ web app.

Select 12 words, and click on “GENERATE”.

Image for post
Image for post

This will generate a list of 12 words that map to a private key.
Let’s keep this mnemonic at hand.

Image for post
Image for post

Further down the page, we select the coin ETH — Ethereum.

Image for post
Image for post

After choosing the coin, the application will derive a set of public keys and addresses that are valid in the Ethereum protocol.

Image for post
Image for post

We can select the first address and fund it through a free Ropsten faucet.

Image for post
Image for post

We copy that address and goto the URL: https://faucet.ropsten.be/.
Paste it in the input field and click on “Send me test Ether”.

Image for post
Image for post

We will receive a confirmation of test Ether being sent to the following address:

0x13E48214f817ea452B594ce6C60B1B9Ea327C098

Which is controlled by a private key, that maps to our 12-word-mnemonic.

region cross fan also tenant boy marble milk evokes hedgehog adult prosper

Truffle.js configuration

We will need to install an npm package before setting up our configuration file. Let’s run the next command in our CDE terminal.

$ npm install -s truffle-hdwallet-provider

We can now begin the configuration of the truffle.js file which is located in our lotteryapp directory.

Start by making use of the package installed earlier:

Image for post
Image for post

Then create a constant mnemonic with our list of 12-words:

Image for post
Image for post

Now we configure the Ropsten network:

Image for post
Image for post

Creating the migration file

We will now create a file in the migrations directory named 2_deploy_contracts.js.

Image for post
Image for post

Inside it, we will reference our Lottery contract.

Image for post
Image for post

Finally, we run the next command to start the migrations and deploy our smart contract to the Ropsten Ethereum Network.

$ truffle migrate --network ropsten

We should see an output similar to this, which indicates our contract has been successfully deployed.

Image for post
Image for post

This is the address of our contract:

Image for post
Image for post

We can check the deployment status by searching for this same address in a Ropsten explorer:

https://ropsten.etherscan.io/address/0x3fa11fb8b1080a68ebb9a439ddfda38d2950433d

We could add more networks to our truffle.js file, allowing us to deploy our contract to other local or public networks as such:

Image for post
Image for post

And deploy the contract to a specific network by following the next structure:

$ truffle migrate --network <Name_of_Network>

Build a smart contract on our BPaaS platform for free if you haven’t known that it’s easy to build, test and deploy a smart contract in the blockchain space.


About Morpheus Labs

The team at Morpheus Labs comes from diverse backgrounds banded together, has created Morpheus Labs BPaaS (Blockchain Platform as a Service), a go-to platform offering mission-critical tools, infrastructure, various blockchain protocols and blockchain use case references for enterprises and developers to build, experiment and manage their own applications effortlessly at minimal cost and time.

Refer to https://docs.morpheuslabs.io for further information about Morpheus Labs BPaaS.


Be a part of our community! Join our official group chat on Telegram: https://t.me/morpheuslabs

(Check out our Community Telegram Guidelines.)


🤳🏼Connect with us:

LinkedIn | Twitter | Telegram | Facebook | Youtube | Github | Reddit | CrunchBase | Website | Gitter

For any query, please contact us at info@morpheuslabs.io.

Morpheus Labs

Powering Blockchain Worldwide

Morpheus Labs Team

Written by

The Blockchain-Platform-as-a-Service (BPaaS) for prototyping, deploying and operating Dapps at minimal cost and time. | https://morpheuslabs.io

Morpheus Labs

The Blockchain-Platform-as-a-Service (BPaaS) for prototyping, deploying and operating Dapps at minimal cost and time. | https://morpheuslabs.io

Morpheus Labs Team

Written by

The Blockchain-Platform-as-a-Service (BPaaS) for prototyping, deploying and operating Dapps at minimal cost and time. | https://morpheuslabs.io

Morpheus Labs

The Blockchain-Platform-as-a-Service (BPaaS) for prototyping, deploying and operating Dapps at minimal cost and time. | https://morpheuslabs.io

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store