Using Oppenzeppelin version 2.8.2 and truffle version v5.1.26
My contract uses
import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol";
contract calls
contract EPNSCore is Initializable, OwnableUpgradeSafe, ReentrancyGuardUpgradeSafe {
using SafeMath for uint256;
/* ***************
* CONSTRUCTORS, MODIFIERS AND FUNCTIONS
*************** */
function initialize( ) public initializer {
but i still get this error
- Contract EPNSCore or an ancestor has a constructor. Change it to an initializer function. See https://docs.openzeppelin.com/upgrades/2.6//writing-upgradeable#initializers.
- Contract EPNSCore imports access/Ownable.sol, GSN/Context.sol, utils/ReentrancyGuard.sol, math/SafeMath.sol, token/ERC20/IERC20.sol from @openzeppelin/contracts. Use @openzeppelin/contracts-ethereum-package instead. See https://docs.openzeppelin.com/cli/2.6/dependencies#linking-the-contracts-ethereum-package.
One or more contracts have validation errors. Please review the items listed above and fix them, or run this command again with the --force option.
1 Like
Hi @Dike_Jude,
I’m sorry that you had this issue. Is your contract importing anything else?
I tried to reproduce using your imports (see MyContract.sol below) but was able to compile:
$ npx oz compile --solc-version 0.6.7
✓ Compiled contracts with solc 0.6.7 (commit.b8d736ae)
MyContract.sol
pragma solidity ^0.6.0;
import "@openzeppelin/contracts-ethereum-package/contracts/access/Ownable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/Initializable.sol";
contract MyContract is Initializable, OwnableUpgradeSafe, ReentrancyGuardUpgradeSafe {
using SafeMath for uint256;
/* ***************
* CONSTRUCTORS, MODIFIERS AND FUNCTIONS
*************** */
function initialize( ) public initializer {}
}
Hi @abcoathup,
I assumed ‘oz deploy’ compiles and deploys.
Meaning i have to compile first before trying to deploy
1 Like
Hi @Dike_Jude,
Apologies, I only did a compile check and didn’t check oz deploy
.
Unfortunately I’m not able to reproduce what you are seeing with my simple example.
Are you able to share your contract, or at least all the imports as I suspect that something that you are importing uses a constructor?
$ npx oz deploy
Nothing to compile, all contracts are up to date.
? Choose the kind of deployment upgradeable
? Pick a network development
? Pick a contract to deploy MyContract
✓ Added contract MyContract
✓ Contract MyContract deployed
All implementations have been deployed
? Call a function to initialize the instance after creating it? Yes
? Select which function * initialize()
✓ Setting everything up to create contract instances
✓ Instance created at 0xCfEB869F69431e42cdB54A4F4f105C19C080A601
To upgrade this instance run 'oz upgrade'
0xCfEB869F69431e42cdB54A4F4f105C19C080A601