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.
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:
- Select a compiler version — pick the version that matches your
pragma soliditydeclaration. 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. - Configure optimization — enable optimization and set the number of runs. Default
runs: 200is suitable for most contracts; lower values produce smaller bytecode at higher runtime Energy cost. - Click Compile — TronIDE compiles the contract and reports any errors inline.
Save your compiler settingsThe 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.
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
- Quickstart — TronBox CLI walkthrough for the same steps
- Solidity on TRON — TRON-specific language extensions
- Deploying — deploy your compiled contract
- Contract verification — verify source on TRONSCAN after deployment
Updated 25 days ago