A Comprehensive Guide on How to Build dApps on Eleven01 Protocol

Eleven01
Eleven01
Published in
7 min readJun 11, 2019

--

Eleven01 is a fast, highly-scalable blockchain protocol that aims to make blockchain ready for the real-world use starting with India as a beachhead market for the public as well as private workloads. Secure-by-default and privacy-focused, Eleven01 protocol employs cutting-edge blockchain research to achieve high throughput through the dynamic consensus and is designed to scale up to several thousand transactions per second.

As a base-layer protocol, our intent is to make things as easy as possible for developers and dApps and taking the pain out of integrating the code with the blockchain. In this article, we are going to walk you through building your first dApp on the Eleven01 blockchain Protocol to showcase the ease of use and available resources at your disposal.

Here are the Prerequisites before we jump into building a dApp:

  • Operating Systems: Ubuntu Linux 16.04 / 18.04 LTS (both 64-bit) or Windows 8 or More or Mac latest versions
  • RAM: 2 GB or More (recommended 8 GB)
  • Geth Setup: https://geth.ethereum.org/downloads/
  • Node JS: 8.9 or higher (download from https://nodejs.org/en/download/
  • NPM: v5.x
  • Git: 2.9.x or higher (https://git-scm.com)
  • Truffle 4.1.15 (global installation): npm install -g truffle@4.1.15
  • Solidity Code 0.4.24 version : https://solidity.readthedocs.io/en/v0.4.24
  • Windows Build Tools (Global Installation): npm install — global — production windows-build-tools
  • Code Editor: Visual studio code or Atom
  • Install truffle-hdwallet-provider: npm install truffle-hdwallet-provider

The article has been divided into 4 phases.

Phase 1

Setting up truffle & dependencies

Phase 2

Writing Smart contract & deploying on Eleven01 Network

Phase 3

Interact with the Deployed contract (with truffle)

or

Phase 4

Interact with the Deployed contract (with Metamask)

Phase 1: Setting up Truffle & dependencies

Please note that this is the configuration that we’re going to be using as a reference for this article.

The Current Laptop Configuration.

Step 1

Create a folder and name it as “Eleven01DApp”.

Step 2

Open the folder in Visual Studio or Atom or in your favourite text editor.

Visual Studio

Step 3

Open Terminal (Ctrl + ‘) and type command “truffle init”

Truffle Init

It creates contracts, migrations & test folder along with truffle-config.js

  1. contract folder contains Migration.sol file
  2. migration folder contains a 1_initial_migration.js file
  3. test folder is empty

Step:4

Initiate npm package in the project and enter the project details.

package.json setup

package.json configuration

It creates package.json file.

Step: 5

Open truffle-config.js file and replace with the below content.

Replace MNEMONIC with your own MNEMONIC

Or you can copy this content from https://developers.eleven01.io/getting-started and your truffle-config.js looks like this.

RPC_ENDPOINT has a URL of Eleven01 Testnet RPC which allows you to interact with Eleven01 Blockchain network.

This is the end of Phase 1!

Phase 2 — Writing and Deployment of Smart Contract on Eleven01 Network

In this phase, we’re going to write a simple smart contract, which shows the default value as Hello World & you can also customize the message and deploy it on Eleven01 Blockchain Platform.

Step 1

Create a file in contracts folder “HelloWorld.sol”.

Step 2

Let’s start the contract by defining the compiler version. In this example, we will be using the version 0.4.24 and the code goes like this.

Step 3

After defining the version, Let’s create a contract and we’re going to name it as HelloWorld.

Step 4

Let’s define a variable for storing the default message.

Step 5

We will create a constructor and store the initial value as “Hello World!”

Step 6

Our contract is ready to deploy, however, we need to add one more function which will allow the user to enter his country and deploy a message.

Step 7

We’d like to further customize the contract hence I made a few changes and the final contract looks like this.

HelloWorld Smart Contract

Step 8

Copy the above-mentioned code and paste it in the file which you have created in Step 1 of this phase. And your project looks like this at this stage.

Hello World Smart Contract

Step 9:

Open 1_initial_migration.js in migrations folder, replace with the below code.

Update artifacts in 1_initial_migration.js with HelloWorld Smart Contract

Step 10:

Now our project is ready to deploy on Eleven01 Blockchain. We can deploy the project in multiple ways, in this article we’re going to show you how you deploy with Truffle & also Remix.

Let’s start deploying with Truffle:

First, we need to compile the code, using the command “truffle compile”, this will create a build folder.

truffle compile

truffle compile

Migrate it to Eleven01 Blockchain network.

truffle migrate — reset — network eleven01

truffle migrate

Now we have successfully deployed our Smart contract to Eleven01 Blockchain Network.

You can visit our Blockchain Explorer and verify the transactions. Lets test one. Open Block Explorer & place the Transaction Hash

0x53ce0bdddbe65911d999feb47743507616941bcfbf9d78fe9e1ecf07e2690b40

Block Explorer View

Search with the Transaction Hash

Search Result

That is the end of Phase 2!

Phase 3 — Interact with the Deployed contract (with truffle)

Let’s start interacting with smart contract. Type the below command to shift to console.

truffle console — reset — network eleven01

After the above command, you will be shifted to console mode.

truffle(eleven01)>

In the console type

HelloWorld.new()

This deploys the smart contract to Eleven01 and returns a contract address.

Copy the contact address and type the below command (replace the below address with your address)

HelloWorld.at(‘0x8004e0d798881d1a385fbbef86f1e5aa9d5be76e’).Country(“Rajesh”)

With this now we have successfully deployed the smart contract & interacted with it.

This is the actual process of deploying and working with a smart contract, however, we have a different method of executing the same contract with the simple and user-friendly way. To execute it in this manner, follow Phase 4.

That is the end of Phase 3!

You can use either Phase 1 to Phase 3 to build and deploy an Eleven01 blockchain application or build the application only with Phase 4.

Phase 4 — Interact with the Deployed contract (with Metamask)

Step 1

Open Remix Editor http://remix.ethereum.org

Step 2

Setup your Metamask (metamask.io)

Step 3

Click on Metamask -> settings -> Advance -> New Network -> Paste ”http://104.40.3.236:8083/api/node/rpc”

Step 4

Create a file HelloWorld.sol & paste the contract and select the Compiler Version to 0.4.24 as shown below

Step 5

Go to Run tab & click on Deploy & click on Confirm.

Your smart contract will be deployed successfully and you see the deployed contract in “Deployed Contracts” section as shown in the image.

Now we have successfully deployed the contract to Eleven01. Click on HelloWorld new deployed contract & click on defaultMessage and you should see a message like this:

Now, let’s add a new country to the contract. Enter country Name & click Country and you would be asked to confirm the transaction again from Metamask. Click Confirm.

After confirming the transaction, it will be submitted to Eleven01 Blockchain. Click on defaultMessage again and you would see “Hello India from Eleven01”

And there you have it! That’s how you successfully build a dApp on Eleven01. We’d be happy to take a look at what you’re building. Feel free to get in touch with us on our social media channels and share your work with us. Happy building!

Here are the few resources:

--

--

Eleven01
Eleven01

The world’s largest blockchain ecosystem, built around India’s only blockchain protocol