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    

Converting Ethereum Contracts

For existing solidity contracts you wish to integrate into the TRON ecosystem, the .sol files can be easily converted via the Tron Studio GUI. First, ensure you have the proper tools set up from the Getting Started page. Once the tools are set up, just follow the steps below.

Import the Solidity File

Navigate to the IDE top left and click on the Import File icon. Select the desired smart contract solidity files and click Open.

Note: Currently opening a solidity file results in two instances of the file being simultaneously opened in the IDE. The second instance has no content. Simply close the second instance. This issue will be addressed in later Tron Studio releases.

Important Note: Units of currency in Tron smart contracts are TRX and sun. To successfully migrate your Ethereum smart contracts to Tron, please change Ether denominations into TRX denominations, while being mindful of the Ether/TRX market exchange rates. Remember that 1 TRX = 1,000,000 sun. The Ether denomination table is listed here for your reference.

For example, in the below figure, the ether term is changed to trx. At the same time, the average exchange rate of TRX to Ether on this day is 8400 TRX to 1 Ether. Thus, after the units are converted, the quantity is also adjusted to ensure minimal change in value.

After importing the desired solidity files, select the "Compile" tab at the top right of the application. Compile each smart contract by clicking the "Compile" button under the tab.

Verify the smart contract successfully compiled with no errors. Note: yellow warning messages are OK, as long as you get the "Compile Result: Success" message.

Next, navigate to the Run tab. Specify the Environment, Account, Fee Limit, Call Value, and User Pay Ratio values used to deploy your smart contract. Also, specify which contract you would like to deploy with the proper constructor parameters.

NOTE: User Pay Ratio

User pay ratio is defined as the ratio of the cost the smart contract user should pay. This parameter accepts any integer between 0 and 100, inclusive. However, it is strongly recommended to set the value between 1 and 99. The reason is to protect yourself, the contract developer, from malicious infinite loop time-out attacks.

Once you have the above parameters specified, click on the "Deploy" button to publish your smart contract on the Tron blockchain.

Note: If your contract fails to deploy due to a “Not enough energy for 'save just created contract code' executing” error, change the “Fee Limit” value from 100 to 1000 (max).

Initiate the deployed contract function calls located under the "Deployed Contracts" section within the "Run" tab. You can also view results and logs of the deployed contract in the logcat window.

Compile the Smart Contract

Select the contract to be compiled. Then hit compile on the right tab bar. In the below example, Fibonacci.sol will be compiled.

Getting Compile Result

After successful compilation, the contract name is highlighted in the right tab bar. Click on Detail for the contract's byte code, abi, and function hashes.

Smart Contract Deployment

In the right tab bar, select the Run tab, and the most recently compiled contract shows in the middle area. The network environment can be selected and customized. In the below example, we connect to the test net

Under the Account drop box, select the account you are using for deployment. You can use another account by selecting the group icon on the top right corner by entering your private key, then selecting the most recently added account. The most recent account always appears on the bottom of the drop list.

Selecting Deploy displays the deployment result and deployment history.

Trigger the Smart Contract

In the Deployed Contracts panel, clicking on the left arrow displays the methods in the contract. The purple indicates events in the function.

Enter the parameters for the function, if it has multiple parameters. Separate each parameter by a comma, then click n the function name.

The result displays in the bottom window.