Aavegotchi Docs
Official WebsiteDapp
  • Welcome to Aavegotchi
    • Introduction
  • Own. Trade. Earn.
    • What is True Ownership?
    • Tokens
      • GHST Token
      • Gotchus Alchemica
      • GLTR Token
    • Game Items
      • Aavegotchis
      • Portals
      • Wearables
      • The Forge
      • Gotchiverse
    • Trading
      • Aavegotchi Baazaar
      • Auction House
    • Earning in Aavegotchi
      • Rarity Farming
      • Staking
      • Playing Games
  • Gaming
    • Aavegotchi Gaming Console
    • Live Games
    • Assets
      • Badges
      • Experience Points
      • Skins
      • [REDACTED]
  • Geist
    • Overview
    • FAQ
  • Governance
    • About AavegotchiDAO
    • Creating a Proposal
    • Voting on Proposals
  • developers
    • Aavegotchi Contracts
      • Reading from Aavegotchi Contracts
        • Fetching Onchain SVGs
      • Writing to Aavegotchi Contracts
      • Extending Aavegotchi Contracts
        • Upgrading
        • Security
        • Deployment
        • Governance
      • About EIP-2535 Diamonds
        • Facets
      • maTokens
      • Concepts
      • Deployed Contracts
        • Aavegotchi Diamond
        • Forge Diamond
        • Wearable Diamond
        • Gotchiverse Realm Diamond
        • Installation Diamond
        • Tile Diamond
    • Subgraphs
      • General
      • Core Matic Subgraph
      • SVG Subgraphs
      • Gotchiverse Subgraph
      • FAKE Gotchi Subgraph
Powered by GitBook
On this page
  • Rules
  • Upgrade Procedure

Was this helpful?

  1. developers
  2. Aavegotchi Contracts
  3. Extending Aavegotchi Contracts

Upgrading

Upgrading the Aavegotchi Diamond

PreviousExtending Aavegotchi ContractsNextSecurity

Last updated 1 year ago

Was this helpful?

As per upgrades are done by calling the diamondCut function to add/replace/remove any number of functions and facets in a single transaction.

Upgrading can be done safely and easily as long as some important rules are followed.

Rules

  1. Make sure that an upgrade is atomic, meaning that all changes are done in a single transaction to ensure the diamond does not get into an inconsistent state. This is done by calling diamondCut once with all functions to add/replace/remove.

  2. The diamond and all the facets share the same contract storage address space. Do not corrupt state variables by sticking new state variables in the middle of structs. Do not change the bit size of an existing state variable if that overlaps with an existing state variable.

  3. New state variables can be added to the end of structs.

  4. Existing state variables can have their name changed.

More info on upgrade rules found here:

Upgrade Procedure

  1. Modify the existing source code of the diamond and its facets.

  2. Write an upgrade script that calls the diamondCut function to add/replace/remove functions.

  3. Write any new tests and run tests to make sure they pass.

  4. Commit and push changes to git.

  5. Get any needed code review or code audit.

  6. Execute the upgrade script.

  7. Immediately with the transaction hash that made the upgrade. Commit and push the tag to git. This records and associates the diamond and facet source code with the upgrade.

  8. Use the hardhat etherscan plugin to verify the source code of any new facets that were used to add/replace functions.

Example upgrade command: npx hardhat run scripts/upgrade.js --network kovan

EIP-2535 Diamond Standard
https://eip2535diamonds.substack.com/p/diamond-upgrades?s=w
tag the source code