Writing & compiling

Write Solidity for TRON and compile with TronIDE, TronBox. This page covers the TronIDE workflow; for command-line workflows, see the TronBox documentation.

📘

Prerequisites

There are several toolchains for writing and compiling TRON smart contracts. The most common are:

  • TronIDE — a browser-based IDE similar to Remix. Best for getting started quickly with no local setup.
  • TronBox — a CLI tool for compiling, testing, and deploying. Best for project-based workflows and CI/CD. See Quickstart for a hands-on walkthrough.

This page walks through the TronIDE workflow because it is the lowest-friction option for new contracts. For command-line workflows, see the TronBox documentation.

Prepare contract files in TronIDE

In the FILE EXPLORER tab, click the Create New File icon to create a new contract file, or select Load a local file into current workspace to import pre-written contract code from your local machine.

TronIDE file explorer with the Create and Load buttons highlighted

If you are starting from a template, the TRC-20 contract template is a good starting point for fungible tokens. For NFTs, see the TRC-721 contract example.

Compile

Open the SOLIDITY COMPILER tab in TronIDE, then:

  1. Select a compiler version — pick the version that matches your pragma solidity declaration. Pin to a specific version (pragma solidity 0.8.6) rather than caret-prefixed (^0.8.6); this prevents subtle behavior changes between minor compiler releases.
  2. Configure optimization — enable optimization and set the number of runs. Default runs: 200 is suitable for most contracts; lower values produce smaller bytecode at higher runtime Energy cost.
  3. Click Compile — TronIDE compiles the contract and reports any errors inline.
TronIDE Solidity Compiler tab with version selector, optimization options, and Compile button
📘

Save your compiler settings

The compiler version, optimization setting, and number of runs are required when verifying the deployed contract on TRONSCAN. Note them down — TRONSCAN's verifier needs the exact same settings to reproduce your bytecode. See Contract verification.

View the compiled artifacts

After a successful compile, click Compilation Details to view the contract's metadata, including the contract name, ABI, bytecode, and compiler input.

TronIDE Compilation Details showing ABI, bytecode, and metadata

The ABI is what front-end SDKs (TronWeb, TronBox migrations, ethers.js) use to encode and decode calls; the bytecode is what gets deployed on-chain.


Related resources