Git Product home page Git Product logo

upgradeable-nft's Introduction

Upgradable NFT

A NFT (ERC721) contract that can be upgraded using OpenZeppelin UUPS proxy pattern.

Installation

git clone https://github.com/ismaventuras/Upgradeable-NFT.git .
npm install

Usage

  • Change secrets_sample.json placeholders for your own information and rename the file to secrets.json

Deploy

  • Change the name and symbol for your NFT on contracts/UpgradeableNFT.sol

  • Deploy the contract using hardhat and the script scripts/deployProxy.js , if you change the contract name you will need to change the CONTRACT_NAME variable inside deployProxy.js

hardhatFolder> npx hardhat run .\scripts\deployProxy.js --network $network
  • Verify the implementation address using hardhat verify
hardhatFolder> npx hardhat verify --network mumbai $implementationAddress
  • Verify the proxy on block explorer, go to the proxy address on block explorer, click on code, then on More Options and finally on "Is this a proxy?". It will open a new window, click on verify and you will be able to use the proxy via block explorer

verify_proxy

Upgrade

  • Set the current proxy address on CURRENT_PROXY_ADDRESS variable and the upgraded contract name on CONTRACT_NAME
hardhatFolder> npx hardhat run .\scripts\upgradeProxy.js --network mumbai
#NOTE: IF THIS COMMAND RETURNS THE PREVIOUS IMPLEMENTATION ADDRESS RUN IT AGAIN
  • Verify the implementation address using hardhat verify
hardhatFolder> npx hardhat verify --network mumbai $implementationAddress
  • You don't need to verify proxy address again, block explorer will automatically show the updated version on the proxy.

Tests

A test script testing the deployment and upgrade of the proxy under tests/UpgradeableNFT.test.js

upgradeableNFT> npx hardhat test .\tests\UpgradeableNFT.test.js


  ✔ deploys and name is UpgradeableNFT (483ms)
  ✔ deploys and is upgraded to V2 (313ms)

  2 passing (2s)

folder distribution

UpgradeableNFT
│   README.md
│   secrets_sample.json
│   package.json
│   hardhat-config.js    

└───contracts
│   │   UpgradeableNFT.sol 

└───scripts
│   │   deployProxy.js
│   │   upgradeProxy.js

└───tests
    │   UpgradeableNFT.test

TL;DR : Do NOT delete .openzeppelin folder

The plugins will keep track of all the implementation contracts you have deployed in an .openzeppelin folder in the project root, as well as the proxy admin. You will find one file per network there. It is advised that you commit to source control the files for all networks except the development ones (you may see them as .openzeppelin/unknown-*.json).

LICENSE

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.