# Truffle cannot flatten openzeppelin/contracts

**URL:** <https://forum.openzeppelin.com/t/truffle-cannot-flatten-openzeppelin-contracts/5065>\
**Category:** Contracts\
**Created:** [December 16, 2020, 3:08pm UTC](https://forum.openzeppelin.com/t/truffle-cannot-flatten-openzeppelin-contracts/5065 "2020-12-16T15:08:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![KL5616](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/kl5616/32/3852_2.png) [@KL5616](https://forum.openzeppelin.com/u/KL5616)\
**Post date:** [December 16, 2020, 3:08pm UTC](https://forum.openzeppelin.com/t/truffle-cannot-flatten-openzeppelin-contracts/5065/1 "2020-12-16T15:08:27Z")

</div>

Having installed npm and truffle, I wish to use  
import “@openzeppelin/contracts/token/ERC20/ERC20.sol”;

to import openzeppelin packages for deploying using Remix. However, I cannot truffle-flatten the main .sol and get an error referring to invalid ALT.

**💻 Environment**

MacOS Big Sur, Truffle v5.1.567, Remix IDE

**📝Details**

```auto
users-mbp:STK user$ truffle-flattener contracts/SimpleToken.sol > contracts/FlattenedSimpleToken.sol
(node:7324) Warning: Accessing non-existent property 'INVALID_ALT_NUMBER' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:7324) Warning: Accessing non-existent property 'INVALID_ALT_NUMBER' of module exports inside circular dependency
Error: None of the sub-resolvers resolved "@openzeppelin/contracts/token/ERC20/StandardToken.sol" location.
    at ResolverEngine.<anonymous> (/usr/local/lib/node_modules/truffle-flattener/node_modules/@resolver-engine/core/build/src/resolverengine.js:35:23)
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/lib/node_modules/truffle-flattener/node_modules/@resolver-engine/core/build/src/resolverengine.js:4:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
users-mbp:STK user$ truffle-flattener contracts/SimpleToken.sol > contracts/FlattenedSimpleToken.sol
(node:7746) Warning: Accessing non-existent property 'INVALID_ALT_NUMBER' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:7746) Warning: Accessing non-existent property 'INVALID_ALT_NUMBER' of module exports inside circular dependency
Error: None of the sub-resolvers resolved "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol" location.
    at ResolverEngine.<anonymous> (/usr/local/lib/node_modules/truffle-flattener/node_modules/@resolver-engine/core/build/src/resolverengine.js:35:23)
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/lib/node_modules/truffle-flattener/node_modules/@resolver-engine/core/build/src/resolverengine.js:4:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

```

**🔢 Code to reproduce**

```auto
pragma solidity ^0.6.2;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol";

contract SimpleToken is ERC20, ERC20Detailed {

    constructor () public ERC20Detailed("SimpleToken", "STt", 18) {
        _mint(msg.sender, 25000000000 * (10 ** uint256(decimals())));
    }
}

```

---

<div class="post-metadata">

**Author:** ![DaveAppleton](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/daveappleton/32/548_2.png) [@DaveAppleton](https://forum.openzeppelin.com/u/DaveAppleton)\
**Post date:** [December 16, 2020, 6:39pm UTC](https://forum.openzeppelin.com/t/truffle-cannot-flatten-openzeppelin-contracts/5065/2 "2020-12-16T18:39:37Z")

</div>

You should try not to flatten your contracts when submitting to etherscan.

Truffle / Hardhat have verification plugins that allow you to create a combined-json format file that can be uploaded instead.

This makes your life easier because it contains version and optimisation data.

If you still need to flatten (e.g. for remix as you mentioned) try [https://github.com/DaveAppleton/SolidityFlattery](https://github.com/DaveAppleton/SolidityFlattery)

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [December 17, 2020, 5:29am UTC](https://forum.openzeppelin.com/t/truffle-cannot-flatten-openzeppelin-contracts/5065/3 "2020-12-17T05:29:36Z")

</div>

Hi @KL5616,

Welcome to the community 👋

As @DaveAppleton said, you should avoid flattening your contract for verification.

See the following for how to use Hardhat to verify: [Verify smart contract inheriting from OpenZeppelin Contracts](https://forum.openzeppelin.com/t/verify-smart-contract-inheriting-from-openzeppelin-contracts/4119)

---

<div class="post-metadata">

**Author:** ![KL5616](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/kl5616/32/3852_2.png) [@KL5616](https://forum.openzeppelin.com/u/KL5616)\
**Post date:** [December 17, 2020, 4:03pm UTC](https://forum.openzeppelin.com/t/truffle-cannot-flatten-openzeppelin-contracts/5065/4 "2020-12-17T16:03:06Z")

</div>

Many thanks for the suggestions; I am indeed deploying via Remix.

Remix is also able to inherit from OpenZeppelin through a github url (import “[https://github.com/](https://github.com/)…”.  
Can I separately verify the Remix deployed contract through hardhat? Or what is in general the recommended way to deploy to the Ethereum network?

Thanks again!

KL5616

---

<div class="post-metadata">

**Author:** ![abcoathup](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/abcoathup/32/415_2.png) [@abcoathup](https://forum.openzeppelin.com/u/abcoathup)\
**Post date:** [December 17, 2020, 8:48pm UTC](https://forum.openzeppelin.com/t/truffle-cannot-flatten-openzeppelin-contracts/5065/5 "2020-12-17T20:48:11Z")

</div>

Hi @KL5616,

It depends on your use case. Remix is great for experimenting.

You can deploy using Remix using GitHub imports for OpenZeppelin and verify using Hardhat converting GitHub imports to npm imports. [Verify smart contract inheriting from OpenZeppelin Contracts](https://forum.openzeppelin.com/t/verify-smart-contract-inheriting-from-openzeppelin-contracts/4119).

If your contract is going to have value, then I suggest appropriate testing (including automated unit tests) and auditing. See: [Points to consider when creating a fungible token (ERC20, ERC777)](https://forum.openzeppelin.com/t/points-to-consider-when-creating-a-fungible-token-erc20-erc777/2915).
