Programming dapp with loom network

Tram Ho

What is Loom Network?

Loom Network is a class 2 extension solution for Ethereum. This is a sidechains DPoS network that allows games and DApps on a blockchain-capable platform while still supporting Ethereum security. It allows developers to run large-scale applications and is the first Ethereum extension solution to be applied into practice.

The Loom SDK

Loom’s core product is the SDK that allows users to quickly build their own blockchain without having to understand the details of the blockchain’s consensus infrastructure or algorithms. Think of it as a blockchain creator of your own.

DAppChains

Loom SDK creates a DAppChain – a two-layer blockchain that uses Ethereum as its base class. Running DApp on the sidechain for Ethereum has several benefits, but most importantly: DAppChains can use consensus rules (like DPoS) to optimize for scalability. Using Ethereum as a base class means that DAppChain-based assets (such as tokens ERC20 and ERC721) can be securely secured.

DApps scalability

Loom SDK allows users to select consensus algorithms and rules to customize scalability or security depending on DApps needs. Loom Network supports DPoS (Delegated Proof of Stake), allowing the development of large-scale online games and social networking applications. These are the first two DApp categories that Loom focuses on developing (although users can build any type of DApp on the Loom SDK). Being linked to Ethereum via Plasma above, it is possible to transfer assets from Ethereum to Dappchain, to understand, the tokens ERC20 and ERC721 are used on DAppChain while still being secured by Ethereum. In short, the Loom SDK allows developers to build the same types of applications they will build on EOS, but supported by Ethereum.

To learn more about Plasma, please refer to the article: https://viblo.asia/p/plasma-giai-phap-cho-su-mo-rong-mang-luoi-blockchain-tiep-theo-ByEZkybY5Q0

ring ring ring … the theory lesson here is the next step is to practice

Run and create simple applications on Loom Network

Download Loom

You can use the command below to download Loom in the current directory:

Installation

Run the following commands in the same directory as the downloaded loom file

Run

Only three commands above have created your own blockchain network ?

Deploy contract on Loom

Let’s start with Solidity + Truffle

You can install Truffle according to the instructions here: https://www.trufflesuite.com/docs/truffle/overview

And learn about Solidity language to write a contract here: https://cryptozombies.io/

Deploying and run from Truffle

Now let’s create a project

Files are created

Write a contract

On the contracts folder, we create a new file called Simplestore.sol that has a function to set a parameter value also for a change of that value, the get function is read only and an event named NewValueSet will have parameter values, as the following example:

Next, add a migration and the file name starts with the number 2 example 2_simple_store.js and the content should be as follows:

Install and configure Loom Truffle Provider

Next step we need to install loom-truffle provider to provide connection between Truffle and Loom DAppChain and configure truffle-config.js

Before configuring truffle-config.js we need to create a key using the command:

loom genkey -a public_key -k private_key

Configure truffle-config.js

Running Truffle deploy command

Now you can deploy contract to Dappchain but remember to run the network using the ./loom command first:

truffle deploy --network loom_dapp_chain

If you have deployed and want to deploy again, use the command

truffle deploy --reset --network loom_dapp_chain

Configure and run Web3.js + LoomProvider

We have deployed the contract to the Dappchain network and then we will interact with that contract via web3.js and LoomProvider.

Install web3.js

Install LoomProvider (it is in loom-js)

After installation is complete, we create a js file named index.js to interact with Dappchain with the following content:

To run this file you can run it by:

node index.js

github complete example:

https://github.com/vinhyenvodoi98/Loomnetwork_Dappchain

Reference sources:

https://loomx.io/developers/docs/en/intro-loom-sdk.html

The introduction to Loom Network as well as the construction of a simple example running on Loom Network here is a very nice ending.

Share the news now

Source : Viblo