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.

5 Likes

Same question. Can we have it in tronbox cli?

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.
3 Likes