Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 1.41 KB

upgradeablecontracts.md

File metadata and controls

34 lines (24 loc) · 1.41 KB

Steps to Create and Deploy Upgradeable Contracts

Install the upgradeable contracts package from OpenZeppelin:
    npm install @openzeppelin/contracts-upgradeable

When writing an upgradeable contract, replace constructors with initializer functions.

example upgradeable ERC-721 contract:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

contract MyUpgradeableNFT is Initializable, ERC721Upgradeable, OwnableUpgradeable {
    function initialize(address owner) initializer public {
        __ERC721_init("MyUpgradeableNFT", "NFT");
        __Ownable_init(owner);
    }
}

upgrading smart contracts
npm install @openzeppelin/contracts-upgradeable @openzeppelin/contracts
OwnableUpgradeable.sol
AccessControlUpgradeable.sol