January 25, 2026

Capitalizations Index – B ∞/21M

Straighten/Flatten Solidity file from JavaScript file

Straighten/Flatten Solidity file from JavaScript file

Solidity has been the primary language for smart contract development. While writing various contracts, we maintain modules for code reuse and management. We imports 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.

const Straightener = require('sol-straightener');
let result = await Straightener.straighten(<solidity/file/path>);

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!

Published at Sat, 11 May 2019 14:10:30 +0000

Previous Article

U.S. Treasury to Name-Shame Vietnam for Manipulating Its Dong

Next Article

Bitcoin’s Hashrate Nears All-Time High – Trustnodes

You might be interested in …

Delmar the poet - i believe ft. Betsy [official video]

DelMar the Poet – I Believe ft. Betsy [Official Video]

DelMar the Poet – I Believe ft. Betsy [Official Video] Download or stream #IBELIEVE here: ➡️ http://hyperurl.co/ibelieveDMTP A portion of proceeds go directly to addiction recovery resources. We’re here for your support. Comment your story […]