Deploying a Contract to the Ethereum Network on Morpheus Labs 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”.
This will generate a list of 12 words that map to a private key.
Let’s keep this mnemonic at hand.
Further down the page, we select the coin ETH — Ethereum.
After choosing the coin, the application will derive a set of public keys and addresses that are valid in the Ethereum protocol.
We can select the first address and fund it through a free Ropsten faucet.
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”.
We will receive a confirmation of test Ether being sent to the following address:
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
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:
Then create a constant mnemonic with our list of 12-words:
Now we configure the Ropsten network:
Creating the migration file
We will now create a file in the migrations directory named 2_deploy_contracts.js.
Inside it, we will reference our Lottery contract.
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.
This is the address of our contract:
We can check the deployment status by searching for this same address in a Ropsten explorer:
We could add more networks to our truffle.js file, allowing us to deploy our contract to other local or public networks as such:
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.