Deploy Smart Contract on TRON Blockchain

Niharika Singh
Coinmonks

--

In this article, I gave a gentle introduction to the TRON blockchain. We discussed the following agendas:

  1. What is TRON and What do they want to do
  2. Future of TRON: Project Atlas
  3. The inner working of TRON
  4. Future of TRX (the cryptocurrency of the TRON blockchain)

Since we are clear on the above-mentioned agendas, I think it is the right time to deploy a dApp on the TRON blockchain. This article is going to be about how we can use the TRON blockchain as a virtual machine.

Source: https://theoofy.com/

Pre-requisites

  • Oracle JDK 1.8
  • TRON Studio
  • Knowledge of solidity, the turing-complete language

A little bit of background…

Like Ethereum Virtual Machine (EVM), TRON is also a turing-complete machine. TRON aims to provide blockchain developers with a custom-built blockchain system that is efficient, convenient, stable, secure and scalable.

This gives the impression that TRON is very similar to Ethereum. Or maybe it is better…?

Source: https://ambcrypto.com/

TRON Studio

TRON Studio is an IDE for developing, deploying, and debugging smart contracts based on TVM. It uses gRPC to register accounts, deploy, and trigger smart contracts. Currently, there is no support for an HTTP gateway.

Step 0: Download the TRON Studio source code

Being an open source platform, the source code of TRON studio is available easily. You can git clone it from here.

After downloading, cd into the directory.

$ cd tron-studio

Step 1: Run and launchTRON Studio

$ ./gradlew build

This may take a while depending how fast your internet and machine are.

$ java -jar build/libs/TronStudio.jar

On launch, something like this would open up:

Step 2: Coding and compiling the smart contract

One of the best parts about developing on TRON is that the dev stack is very similar to Ethereum. No new language has to be learned to execute the contracts. Our dear old Solidity works perfectly fine!

My all-time favorite program is to add two numbers! So let’s do that.

pragma solidity ^0.4.24;contract Addition {
int public sum = 0;

function add (int x, int y) public {
sum = x + y;
}
}

Click on COMPILE in the IDE. You should see something like this:

Step 3: Run the smart contract

Go on the RUN tab and click on DEPLOY. You should see something like this.

Step 4: Let’s Add the numbers!

Click on the deployed contract under Deployed Contracts. You should see such an interface.

Let’s pass in the parameters and click add.

Now to get the sum, let’s click on sum.

You see contract result is 10!

If you see this, then you’ve successfully deployed a smart contract on the TRON blockhain.

--

--