I flattened my files and they compile no problem on Remix, but when I try to upload them to Etherscan, they won't accept it with the error:

 Compiler debug log:
Error! Unable to generate Contract ByteCode and ABI (General Exception, unable to get compiled [bytecode])
For troubleshooting, you can try compiling your source code with the Remix - Solidity IDE and check for exceptions

Compiler Warning(s):

DeclarationError: Identifier not found or not unique.
    --> APIConsumer.sol:1095:5:
1095 |     ENSResolver_Chainlink resolver = ENSResolver_Chainlink(s_ens.resolver(linkSubnode))
     |     ^^^^^^^^^^^^^^^^^^^^^

This is the first part of my APIConsumer file before I flattened it.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";

contract APIConsumer is ChainlinkClient {
    using Chainlink for Chainlink.Request;
    bytes32 public api_data;
    address private oracle;
    bytes32 private jobId;
    uint256 private fee;

After I flattened it (to which I uploaded to etherscan):

// File: @chainlink/contracts/src/v0.8/vendor/ENSResolver.sol

pragma solidity ^0.8.0;

abstract contract ENSResolver {
  function addr(bytes32 node) public view virtual returns (address);

And the file carries on with all the functions it inherits for another 1000 lines.

Did I do something wrong with flattening? I don't want to disturb peace and up breaking things just to publish my programs as my contracts work fine. How would I debug this problem?

EDIT: The other sighting of ENSResolver in the file:

   * @notice Sets the stored oracle and LINK token contracts with the addresses resolved by ENS
   * @dev Accounts for subnodes having different resolvers
   * @param ensAddress The address of the ENS contract
   * @param node The ENS node hash
  function useChainlinkWithENS(address ensAddress, bytes32 node) internal {
    s_ens = ENSInterface(ensAddress);
    s_ensNode = node;
    bytes32 linkSubnode = keccak256(abi.encodePacked(s_ensNode, ENS_TOKEN_SUBNAME));
    ENSResolver_Chainlink resolver = ENSResolver_Chainlink(s_ens.resolver(linkSubnode));

   * @notice Sets the stored oracle contract with the address resolved by ENS
   * @dev This may be called on its own as long as `useChainlinkWithENS` has been called previously
  function updateChainlinkOracleWithENS() internal {
    bytes32 oracleSubnode = keccak256(abi.encodePacked(s_ensNode, ENS_ORACLE_SUBNAME));
    ENSResolver_Chainlink resolver = ENSResolver_Chainlink(s_ens.resolver(oracleSubnode));
  • 1
    Please inclde the part of the code where ENSResolver_Chainlink resolver = ENSResolver_Chainlink(s_ens.resolver(linkSubnode)) appears, that seems to be the actual problem
    – Julissa DC
    Jul 12, 2022 at 19:11
  • I do not know what your purpose is to use a flattened contract, but for the sake of efficiency, I use hardhat to verify my contracts through the Standard-Json-Input method. Read the docs. You only need to know like 4 commands to get started with it. Jul 12, 2022 at 20:13
  • I typically use brownie to verify my contracts but it one day stopped publishing my contracts. I'll give that a shot. And thank you @JulissaDC, I ended up deleting the _Chainlink to the ENSResolver and got rid of that error... only to find several more (just warnings of unused variables and mismatches of bytecode). I'll give Gray's advice a shot. Thank you.
    – Domini
    Jul 12, 2022 at 20:30

1 Answer 1


Looks like Remix Flattener trimmed a piece of the name of that abstract contract. This approach worked for me:

  1. Flatten contract using Remix IDE plugin
  2. Paste it inside the Etherscan verification field
  3. Rename abstract contract ENSResolver to abstract contract ENSResolver_Chainlink
  4. Hit "Verify"

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.