Is there a tool like the subject for Solidity. Let's say I have a contract with import and that import has three imports etc. I'd like to combine all of them into one file and play with it in Remix, for example.

I know how to make it manually.

  • 1
    I think browserify.org makes more sense in this question since you also want a loader to be able to read from node_modules folder that were installed with npm or ethpm – rstormsf Jul 7 '17 at 5:25
  • 1
    @rstormsf I'd like to combine only .sol files from all corresponding files into one new file. I agree that require.js is not the right analogy – Igor Barinov Jul 7 '17 at 5:27
  • Well, if you use something like openZeppelin installed from npm, u really want it to be able to load all of it from the right folders – rstormsf Jul 7 '17 at 5:29
  • 2
    I don't have much exposure to remix. Is there a possibility of executing the contract's definition in JSON file? If yes then we can generate it using solc compiler. That JSON will have ABIs of all dependent contracts. Let me know if this can work out, I'll share the command. – Sanchit Jul 7 '17 at 5:31
  • 1
    @Sanchit, whatever works, it's interesting idea, yes I can generate compiled JSON files – rstormsf Jul 7 '17 at 5:33

Use sol-merger. This works like a charm. It creates a separate folder and put the merged contracts there.

| improve this answer | |
  • Thanks Aniket, yes this works like a charm.I tried and happy from result. – Chirag Maliwal May 14 '18 at 6:54
  • your welcome @chiragmaliwal – Aniket May 15 '18 at 9:08
  • 1
    Thank you, it works for me! – Dmytro Zarezenko Mar 10 at 10:17

I'd also suggest you to try this - http://remix.readthedocs.io/en/latest/tutorial_remixd_filesystem.html

This feature is currently an alpha version but it may help you.

| improve this answer | |
  • It did work, thank you. although, if there are any shared files besides .sol files a page crash. – Igor Barinov Jul 7 '17 at 6:05
  • Eh, for verifying smart contract code on etherscan e.g. kovan.etherscan.io/… I still need to have a flat file with all imports. May be you'll have ideas how to automate it – Igor Barinov Jul 9 '17 at 15:28
  • 2
    I just had a look, the idea I had is to generate JSON file combining definition of all contracts using solc compiler but I don't think it would work here. The combined JSON worked fine when I deployed contract with multiple imports in web3js but here, in this case, I'm not sure. – Sanchit Jul 10 '17 at 6:20

please have a look on : solidity-flattener

This script automatically traverses the dependency graph and outputs all of your imports in the correct order, ready to be pasted into the contract verifier.

| improve this answer | |

just for the information. I created a plugin for VSCode so you can use it instead of sol-merger because it is based on it under the hood.

Here is the link for plugin: Solidity Contracts Merger.

Hope you will like it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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