July 5, 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 …

How to buy bankcoin

How To Buy Bankcoin

How To Buy Bankcoin How To Buy Bankcoin 👉Buy Bankcoin: https://bankcoin.io/?ref=281345082977 Disclaimer: ICO REVIEWS is not financial adviser. Do not invest more than your willing to lose. You may lose your entire investment in case […]

Cryptocurrency Exchange Kraken Withdraws from Japanese Market

Altcoin Today Cryptocurrency Exchange Kraken Withdraws from Japanese Market Cryptocurrency Exchange Kraken Withdraws from Japanese Market Cryptocurrency exchange Kraken is suspending all of its services to Japanese residents. The exchange has been allowed to operate […]

Top 5: best bread machine 2018

TOP 5: Best Bread Machine 2018

TOP 5: Best Bread Machine 2018 Are you looking for the best bread machine? Well, you’ve come to the right place, in this video Jeremy breaks down the top 5 bread machines, giving you both […]