Hi @lucianstroie,
OpenZeppelin SDK (previously ZeppelinOS) creates upgradeable contracts.
I recommend using the latest version which is OpenZeppelin SDK 2.6
If you are using OpenZeppelin SDK and upgradeable contracts you need to use @openzeppelin/contracts-ethereum-package
rather than @openzeppelin/contracts
.
https://docs.openzeppelin.com/sdk/2.5/linking
NOTE: Make sure you install@openzeppelin/contracts-ethereum-package
and not the vanilla@openzeppelin/contracts
. The latter is set up for general usage, while@openzeppelin/contracts-ethereum-package
is tailored for being used with the OpenZeppelin SDK. This means that its contracts are already set up to be upgradeable.
I recently created an issue to add a warning to users when they create a contract importing @openzeppelin/contracts
: OpenZeppelin/openzeppelin-sdk#1297 .
There is also a plan to remove this requirement to use the Contracts Ethereum Package version: Planning the demise of OpenZeppelin Contracts’ evil twin.
Also with upgradeable contracts we need to use initializer
s rather than constructors.
https://docs.openzeppelin.com/sdk/2.5/writing-contracts
You can use your Solidity contracts in the OpenZeppelin SDK without any modifications, except for their constructors. Due to a requirement of the proxy-based upgradeability system, no constructors can be used in upgradeable contracts.
An example upgradeable ERC721 is as follows:
Simple721Token.sol
When the contract is created (openzeppelin create
) need to ensure it is initialized passing in the address to have the minter role.
Tokens can then be minted by calling (openzeppelin send-tx
) mintWithTokenURI
pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/ERC721Full.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC721/ERC721Mintable.sol";
contract Simple721Token is Initializable, ERC721Full, ERC721Mintable {
function initialize(address sender) public initializer {
ERC721.initialize();
ERC721Metadata.initialize("Simple721Token", "721");
ERC721Enumerable.initialize();
ERC721Mintable.initialize(sender);
}
}