11th Feb 2020

Deploy your first Smart Contract on Loom Network using Remix

Blockchain

Written By, Meet Siraja

Introduction to Loom Network:

loom
Loom Network is a platform to help the Ethereum scale. Loom Network provides a Layer 2 solution that uses Ethereum as it’s the base layer. Using Ethereum as a base layer means base chain assets like ERC20 & ERC721 tokens can have security guarantees of the Ethereum.

The loom is the perfect solution for building scalable applications with almost no transaction cost and very less amount of time for transaction confirmation.

If you don’t know more about the Loom Network and are curious to know, then you can check this handy guide where you can get more ideas about the Loom Network.

Without wasting time, let’s go through the process of deploying smart contracts on the Loom Basechain.

How to Deploy Smart Contract on Loom Chain:

It’s easy to deploy smart contracts on the loom.

Steps to deploy Smart Contract on Loom:

  1. Integrate Remix with Loom
  2. Writing your Smart Contract
  3. Deploy Smart Contract on Loom from Remix IDE.

It’s that simple! Isn’t it?

loom-gif

Step 1: Integrate Remix IDE with Loom

To integrate Remix with loom it requires services that proxies JSON RPC call to Loom. For that, Loom had built a small JSON RPC Proxy. So, here we will install and configure it with the Remix IDE to deploy our smart contract on Loom.

Prerequisites to install JSON RPC Proxy:

  • Node.js 10 or higher(recommended v10.15.3)
  • Yarn
  • Git client
  1. Clone the JSON RPC Proxy repository:
    Open a terminal, cd into your project directory and execute below command:
  2. Install Dependencies and Build the Proxy:
    For that run below command,
  3. Configure the Proxy:
    You need to configure a proxy to connect to Loom Testnet or Loom Basechain. For that, you need to set the following environment variables,PORT: port on which proxy listens for incoming requests. The default port is 8080.
    CHAIN_ID: Network Id you want to connect to. default for Mainnet & extdev-plasma-us1 for Testnet. By default, it will connect to Loom Mainnet.
    CHAIN_ENDPOINT: the address of the endpoint. The default value is wss://plasma.dappchains.com.Run below command to run proxy against Loom Testnet.

    Run below command to run proxy against Loom Basechain. Make sure deploying smart contracts on Loom Mainnet isn’t free. To deploy a smart contract on Loom Mainnet you need to whitelist your address, which will cost you around 1400 Loom per year ATM.

Step 2: Writing your Smart Contract

Here is our Smart Contract example. It is a very simple smart contract that stores string messages and retrieve it from smart contracts. This is just for demo purposes. You can also use your smart contract code

Step 3: Deploy Smart Contract on Loom

First of all, we need to configure Remix to use Loom JSON RPC Proxy. For that open Remix Editor. Click on the Run menu and then select the Environment as Web3 Provider.loom-contractNow you are good to deploy our solidity Smart Contract to Loom Network. Paste below smart contract code into Remix. Select the appropriate compiler version and compile a smart contract by clicking the Compile button.loom-compileAfter compiling a smart contract you can deploy your smart contract by just clicking the Deploy button.loom-deploy

Conclusion

Cheers. You just deployed your first smart contract code on the Loom network. I hope from now onwards you can deploy smart contracts on the Loom Network. If you have any confusion feel free to comment below.

Stay tuned!

Written By,

Blockchain Developer at Yudiz Solutions Pvt. Ltd