I am trying to publish contracts on etherscan on an already deployed address. How would I "flatten" these imported files;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

I tried

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.7.0/contracts/access/Ownable.sol"
import "https://github.com/smartcontractkit/chainlink-brownie-contracts/blob/main/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"

And I get the error:

Source "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.7.0/contracts/access/Ownable.sol" not found: File import callback not supported

What am I doing wrong?

5 Answers 5


There is an add on extension on the Remix IDE where it does it for you automatically.

Check out: https://remix-project.org/

  • I went and dug up this video on flattening as I got fed up with trying to debug why javascript module wasn't working for me. Flattened my files out like pancakes. Thank you! youtube.com/watch?v=-Z_VHCiMwiU
    – Domini
    Commented Jul 12, 2022 at 16:32

If you are not going to use it from Remix I'd recommend this solidity-flattener. Works pretty well for me. Very easy and flexible to use.

  • Cool, I ended up following this lad's tutorial on flattening files... medium.com/coinmonks/… To which I'm finding other errors, which I'll open up another question for. But thank you for leading me in the right direction!
    – Domini
    Commented Jul 12, 2022 at 16:20

In Visual Studio Code you can flatten smart contacts using Solidity extension from Nomic Foundation by right-click on the file you want to flatten and choosing Hardhat: Flatten this file and its dependencies option. It works pretty well with all imported contracts and dependencies.

enter image description here


If you're using Remix , then you have an option to flatten your contract . Just right click on the smart contract file and you can see the option to flatten your contract . enter image description here


If you develop with truffle you can use truffle-plugin-verify to verify a smart contract with a single command in the console without have to flatten any file.

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.