The TRON Developer Hub

Welcome to the TRON developer hub. You'll find comprehensive guides and documentation to help you start working with TRON as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Setup DApp Environment

Introduction

Currently, we can reduce the development cost by setting up a smart contract environment on TRON's private chain, which does not consume the public chain resources. TRON's virtual machine is highly compatible with that of Ethereum, and most smart contracts written in Solidity can also run on TRON network. TRON-based smart contracts provide high TPS and free access to most scenarios for its users. This is undoubtedly a significant step for the entire smart contract community. This article introduces a basic method to deploy smart contracts and interact with them.

Prerequisites

TRON Network for Running the Contract

Deploying and using contracts requires consuming a certain amount of resources (memory, CPU, and storage etc.). Therefore, it is recommended that the developers tune and test their smart contracts on their private networks, and confirm the contract is available before deploying them on the TestNet or MainNet. Please see TRON-CLI for details on deploying a Full Node, or TRON Docker Quickstart for steps on deploying a private network.

The address of the private chain's block-creation node: TPL66VK2gCXNCD7EJg9pgJRfqcRazjhUZY

Witness Private Key: da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0

TRON Box

TRON Box is a framework for testing, compiling, and deploying TRON smart contracts and DApps. The TRON Box Guide details setup and deployment steps.

Smart Contract Development

At this point, we recommend Remix as the coding environment for compiling and testing during the early stages. After the contract is finished, developers can copy the contract to SimpleWebCompiler for further development and then acquire ABI and ByteCode. We present a simple solidity code example of data access, to illustrate the compiling, deployment, and debugging process.

    pragma solidity ^0.4.0;
    contract DataStore {
    
        mapping(uint256 => uint256) data;
    
        function set(uint256 key, uint256 value) public {
            data[key] = value;
        }
    
        function get(uint256 key) view public returns (uint256 value) {
            value = data[key];
        }
    }

1. Initiate the Private Chain

Ensure the private chain in the prerequisite has been successfully deployed by checking FullNode/logs/tron.log and see if the log message "produce block successfully" of persistent block generation appears.

2. Develop Smart Contracts

Copy the code mentioned above to Remix to compile and debug. Make sure the code logic is correct, and the code itself is bug-free.

3. Compile in SimpleWebCompiler

The TRON compiler is slightly different from that of Ethereum and is still integrating with Remix. Therefore, we are providing a temporary way of acquiring ABI and ByteCode instead of acquiring them directly from Remix. Copy the code above to SimpleWebCompiler and click the Compile button to attain ABI and ByteCode.

4. Deploy Smart Contract via TRON Box

Please refer to the TRON Box Smart Contract Deployment guide for more information.