Contract `MyContract` has a constructor When Including "constructor() initializer {}"

I am developing a Smart Contract using OpenZeppeling Upgradeable Contracts. I have installed the following (I had initially installed the "standard" non-upgradeable Contracts, but have removed them afterwards - not sure if anything has been left behind...):

  "dependencies": {
    "@openzeppelin/contracts-upgradeable": "^4.3.2",
    "@truffle/hdwallet-provider": "^1.4.2",
    "fs": "0.0.1-security"
  },
  "devDependencies": {
    "@openzeppelin/truffle-upgrades": "^1.10.0"
  }

If I include the constructor() initializer {} code in my Smart Contract, I obtain the following error during deployment, which appears to point to OpenZeppelin and Truffle modules (e.g. @openzeppelin/upgrades-core, @openzeppelin/truffle-upgrades and truffle/build/webpack...):

../project:/contracts/MyContract.sol:15: Contract `MyContract` has a constructor
    Define an initializer instead
    https://zpl.in/upgrades/error-001
    at assertUpgradeSafe (.../node_modules/@openzeppelin/upgrades-core/src/validate/query.ts:19:11)
    at deployImpl (.../node_modules/@openzeppelin/truffle-upgrades/src/utils/deploy-impl.ts:44:20)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at deployProxy (.../node_modules/@openzeppelin/truffle-upgrades/src/deploy-proxy.ts:35:26)
    at module.exports (.../migrations/2_deploy_contract.js:9:3)
    at Migration._deploy (/usr/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:75:1)
    at Migration._load (/usr/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:56:1)
    at Migration.run (/usr/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:217:1)
    at Object.runMigrations (/usr/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
    at Object.runFrom (/usr/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at Object.runAll (/usr/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:114:1)
    at Object.run (/usr/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:79:1)
    at runMigrations (/usr/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:258:1)
    at Object.run (/usr/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:223:1)
    at Command.run (/usr/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:183:1)
Truffle v5.4.16 (core: 5.4.16)
Node v14.18.1

If I do not include the line, the Contract deploys properly. What is the root cause of the problem? Is it possible that since I had initially installed the standard version of the OpenZeppeling Contracts, that some packages were not properly removed? From my understanding, that additional line of code is supposed to be included mainly for UUPS Smart Contracts. Can I omit it if I am deploying a TransparentUpgradeableProxy Contract?

Thank you. J

1 Like

Solution to this problem can be found at the following https://forum.openzeppelin.com/t/security-advisory-initialize-uups-implementation-contracts/15301/23