How to process all includes in a .sol file? I want to produce a file with all includes recursively replaced with the included files content.

  • 3
    truffle-flattener already does that. Apr 9, 2020 at 15:34
  • 1
    Out of curiosity, why do you want to do that? Apr 10, 2020 at 4:09
  • @soliditydeveloper.com I (mistakenly) thought that this is the only way to verify a contract of several files at Etherscan. It seems the way, however, if a contract includes contracts from other directories.
    – porton
    Apr 10, 2020 at 12:38
  • 1
    @porton If you are using Truffle, you can check out github.com/rkalis/truffle-plugin-verify. It doesn't always work, especially for very new solc versions or proxy contracts for example. But otherwise works pretty well. Apr 10, 2020 at 20:25

1 Answer 1


What I did to get verified on Etherscan and generate my ABI is make a directory and place all your .sol files in it, go in to node_modules/@... and get each .sol dependency and place it in the directory you made. Go in to each .sol file in your directory and replace all the include paths to the current directory. Then you can do the multi-file upload to Etherscan, upload each .sol file and Etherscan flattens it all out and compiles it, gives you the ABI and your source is verified.

You do this Automatically with:

npm install truffle-flattener —save

Then flatten the files this way:

./node_modules/.bin/truffle-flattener ./node_modules/@openz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.