Would you happen to have an example of making the contract initializable/upgradeable in OpenZeppelin v3?
1 Like
Hi @PradhumnaPancholi ,
We need to use OpenZeppelin Contracts Ethereum Package, the contract names have UpgradeSafe
suffix, and instead of constructors we need to use an initializer
:
A great place to start is the Preset ERC20PresetMinterPauser in OpenZeppelin Contracts Ethereum Package:
pragma solidity ^0.6.0;
import "../access/AccessControl.sol";
import "../GSN/Context.sol";
import "../token/ERC20/ERC20.sol";
import "../token/ERC20/ERC20Burnable.sol";
import "../token/ERC20/ERC20Pausable.sol";
import "../Initializable.sol";
/**
* @dev {ERC20} token, including:
*
* - ability for holders to burn (destroy) their tokens
* - a minter role that allows for token minting (creation)
* - a pauser role that allows to stop all token transfers
*
* This contract uses {AccessControl} to lock permissioned functions using the
* different roles - head to its documentation for details.
*
* The account that deploys the contract will be granted the minter and pauser
This file has been truncated. show original
We can use OpenZeppelin Upgrades Plugins for Truffle and Buidler to deploy upgradeable contracts: https://docs.openzeppelin.com/upgrades-plugins/1.x/
If you get stuck I can put together a simple example.