# Upgrade from ERC20Upgradeable to ERC20Upgradeable, EIP712Upgradeable

**URL:** <https://forum.openzeppelin.com/t/upgrade-from-erc20upgradeable-to-erc20upgradeable-eip712upgradeable/32419>\
**Category:** Support\
**Created:** [October 12, 2022, 3:18pm UTC](https://forum.openzeppelin.com/t/upgrade-from-erc20upgradeable-to-erc20upgradeable-eip712upgradeable/32419 "2022-10-12T15:18:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NewKidOnTheBlock](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@NewKidOnTheBlock](https://forum.openzeppelin.com/u/NewKidOnTheBlock)\
**Post date:** [October 12, 2022, 3:18pm UTC](https://forum.openzeppelin.com/t/upgrade-from-erc20upgradeable-to-erc20upgradeable-eip712upgradeable/32419/1 "2022-10-12T15:18:25Z")

</div>

Hello, I'm trying to upgrade a simple ERC20Upgradeable adding EIP712Upgradeable to the inheritance chain

#### 🔢 Code to reproduce

before

```auto
contract Token is ERC20Upgradeable { }

```

after

```auto
contract Token is ERC20Upgradeable, EIP712Upgradeable {}

```

and I'm receiving the following error when running

```auto
  await upgrades.validateUpgrade(TokenV1, TokenV2, {});

```

```auto
Error: New storage layout is incompatible

@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol:30: Inserted `_HASHED_NAME`
  > New variables should be placed after all existing inherited variables

```

Note: I also tried to add ERC2771ContextUpgradeable.sol to the inheritance chain, which gave similar issues, I'm trying to solve one at a time, but a general solution would be really useful (Final inheritance chain should be  
`contract Token is ERC20Upgradeable, EIP712Upgradeable, ERC2771ContextUpgradeable {}`

#### 💻 Environment

Solidity version: "0.8.7"

```auto
"dependencies": {
        "@openzeppelin/contracts-upgradeable": "^4.5.0",
      },
      "devDependencies": {
        "@nomiclabs/hardhat-ethers": "^2.2.0",
        "@nomiclabs/hardhat-web3": "^2.0.0",
        "@openzeppelin/hardhat-upgrades": "^1.21.0",
        "ethers": "^5.7.1",
        "hardhat": "^2.8.0",
        "web3": "^1.7.0"
      }

```

---

<div class="post-metadata">

**Author:** ![Skyge](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.openzeppelin.com/skyge/32/343_2.png) [@Skyge](https://forum.openzeppelin.com/u/Skyge)\
**Post date:** [October 13, 2022, 2:55pm UTC](https://forum.openzeppelin.com/t/upgrade-from-erc20upgradeable-to-erc20upgradeable-eip712upgradeable/32419/2 "2022-10-13T14:55:38Z")

</div>

Just like the error message: `Error: New storage layout is incompatible`

When you want to add some new variables, you had better add them at the end of all variables, in your case, original contract variables are:

```auto
ERC20Upgradeable_Variable
Token_Variable

```

And the new contract you want to upgrade:

```auto
ERC20Upgradeable_Variable
EIP712Upgradeable_Variable // <<<<----- insert some variables, DISALLOWED
Token_Variable

```

It is dangerous to upgrade your contract in your way, it will mix up the original data of the contract.

I think you can read some docs about the upgrade, e.g.  
[Writing Upgradeable Contracts - OpenZeppelin Docs](https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#modifying-your-contracts)
