Manage OZ version


Currently, I am working on a project that use @openzeppelin/contracts version 3.4.0, I have already deployed on Mainnet some contracts that inherit from OZ contracts with this version.
Now I want to add ERC20Votes extension that is part of 4.x version.
What would be the best approach to manage the version in this case? Upgrading the OZ contract package to 4.x would break something?

Thank you.

If you're asking about an upgradeable contract, no you cannot upgrade from 3.x to 4.x. You would have to backport the ERC20Votes code so it is compatible, and you will run into the fact that ERC20 does not have the _afterTokenTransfer hook that is needed.

ok, I understand.
In my case, I haven't created the upgradeable token contract yet, but when I create that token, I would have to update the version of @openzeppelin/contracts of my project (repo) to 4.x or it is better o create a new repo?

In that case you can update your existing repository to 4.x. It should mostly work, and we have a script to help migrate some contracts that moved to a different location. See How to upgrade from 3.x in the changelog.

Thanks for your answer.
In my case wasn't viable to upgrade my repo, because I got some conflicts with the solidity version of the contracts. I am using version 0.6.4 that is incompatible with the version of the OZ contracts (0.8.0).
I think I could change the version of my current contracts, but I am not sure if that would generate more compatibility issues between the code and the versions.

Changing Solidity version should not affect compatibility. Ideally try to use the latest versions so you can use the new features.