How to verify contracts with subdirectory structures in Tronscan with Tronbox

Hi for all! I have some contracts that I publish with Tronbox. The problem I have is that when I try to verify the contracts, as I use OpenZeppelin as a library, I cannot verify them from the Tronscan platform. With Hardhat and other networks, I can do it with a plugin that allows me to verify the contracts, but I cannot find a way to do it with Tronscan and Tronbox. The problem is not with OpenZeppelin itself, but with any contract structure that has includes from subdirectories. This is a significant problem because it does not allow for a coherent structure in large and complex projects. Has anyone experienced this problem and found a solution? In Hardhat, I use the hardhat-etherscan plugin for these cases.

13 Likes

Same question. Can we have it in tronbox cli?

1 Like

Due To Tronscan not supporting subdirectory now. Please follow this guide to flatten your contract files first, and then verify on Tronscan again.

  1. Flatten the contract code with TRONBOX: Flattening your contracts
  2. Update the Licence Identifier: Please manually remove “Duplicated SPDX identifier” incase there are multi identifiers in the flattened file. Add the needed Licence Identifier here too accordingly. Learn more at [hardhat-flatten] Removing duplicated SPDX identifier · Issue #1050 · NomicFoundation/hardhat · GitHub.
  3. Verify the contract with the flattened sol file on TRONSCAN.
8 Likes

@admin.hackathon @support.hackathon

please I am facing the same issue but in my code I have no sensitive word, I haven tron to update the reputation of my token but no response yet . The token name is ZETHILUIM (ZTM) and the contract address is TKZV1gpXVRkqSNYExykk1LgkiEv4po4w9T, please the necessary authority help me look into this.

1 Like

An alternative would be to flatten using Ethereum’s Remix IDE - https://remix.ethereum.org/

You’ll need to add/import your project contracts to the IDE.

Be sure that you have the right compiler settings as defined in your sol and enable optimization with 200 runs.

Then in the Files tab, right click on the sol file you want to flatten and you’ll see the flatten option in the context menu -

Once clicked, the flattened file will be generated which you can then download and upload unto Tronscan to verify your contract.

This method worked smooth for me.


Note: Tron IDE https://www.tronide.io/ - does not have this flatten option in its context menu nor the newer stuff that Remix IDE has.

2 Likes

Is it the same problem where a smart contract does not display code tab and instead displaying contract published?