Which package to use for upgradable and ownable contracts?

Hi @dappCoder,

Welcome to the community :wave:

We should use OpenZeppelin Contracts Upgradeable (OpenZeppelin Contracts Ethereum Package was the previous OpenZeppelin Contracts upgradeable version).

See the documentation for how to use:

https://docs.openzeppelin.com/contracts/3.x/upgradeable#multiple-inheritance

If you need an example, you can check out the ERC721 preset:

Your contract could look something like the following:

// contracts/MyContract.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";

contract MyContract is
    Initializable,
    ContextUpgradeable,
    OwnableUpgradeable,
    ERC721Upgradeable
{
    function initialize() public initializer {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __ERC721_init_unchained("MyCollectible", "MCO");
        __Ownable_init_unchained();
    }
}

Please note OpenZeppelin Contracts 4.0 Beta is going to be released soon, see: Contracts 4.0 Timeline.

Depending on your timeline you may want to use OpenZeppelin Contracts 4 when it is released.


As an aside you can Format code in the forum.