sol-straightener: Straighten/Flatten Solidity file from JavaScript file

Aniket
Coinmonks
2 min readMay 11, 2019

--

Solidity has been the primary language for smart contract development. While writing various contracts, we maintain modules for code reuse and management. We import the code from various files in our main file.

imports in smart contract

For various purposes like to verify contract on Etherscan (Although sol-verifier handles it internally using this), we need a straightened (One file with all imported files data) file. There are multiple CLI utilities available which do this but if one is required to handle it inside a javascript file, sol-straightener can be a right choice.

How to use

It is very simple to use. One need to require the module and provide the path of solidity file.

Import straightened file contents will be returned.

Support

Importing of file is possible in various ways. Currently sol-straightener handles import of files from:

  • relative directories, e.g; import "./lib/SafeMath.sol";
  • node_modules directory, e.g; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
  • Github, e.g; import "github.com/oraclize/ethereum-api/oraclizeAPI_0.5.sol";

Hope this will help Solidity developers out there.

If anyone thinks that there should be any other utility which can help Solidity developers, let me know in the comments below.

Thanks for reading!

Get Best Software Deals Directly In Your Inbox

--

--