Skip to content

Commit 2996b7f

Browse files
Michiel Muldersgitbook-bot
Michiel Mulders
authored andcommitted
Update wording for explanation about upgrade proxy pattern
1 parent 96d860a commit 2996b7f

3 files changed

+24
-11
lines changed

tutorials/smart-contracts/how-to-mint-and-burn-an-erc-721-token-using-hardhat-and-ethers-part-1.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ You can take a look at the **complete code** in the [**Hedera-Code-Snippets repo
3131
5. [Adding the Burn Functionality](how-to-mint-and-burn-an-erc-721-token-using-hardhat-and-ethers-part-1.md#step-5-adding-the-burn-functionality)
3232
6. [Burning an NFT](how-to-mint-and-burn-an-erc-721-token-using-hardhat-and-ethers-part-1.md#step-6-burning-an-nft)
3333

34+
***
35+
3436
## Step 1: Project Setup
3537

3638
#### Initialize Project 
@@ -319,6 +321,8 @@ npx hardhat run scripts/burn.js --network testnet
319321

320322
**Congratulations! 🎉 You have successfully learned how to deploy an ERC-721 smart contract using Hardhat, OpenZeppelin, and Ethers. Feel free to reach out in** [**Discord**](https://hedera.com/discord)**!**
321323

324+
***
325+
322326
## Additional Resources
323327

324328
* [OpenZeppelin ERC-721 Documentation](https://docs.openzeppelin.com/contracts/5.x/erc721)

tutorials/smart-contracts/how-to-set-access-control-a-token-uri-pause-and-transfer-an-erc-721-token-using-hardhat-part-2.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ Compile your new contract:
114114
npx hardhat compile
115115
```
116116

117+
***
118+
117119
## Step 2: Deploying the Smart Contract and Minting a Token
118120

119121
Create `deploy-advanced.js` in your `scripts` folder:

tutorials/smart-contracts/how-to-upgrade-an-erc-721-token-with-openzeppelin-uups-proxies-and-hardhat-part-3.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ You can take a look at the **complete code** in the [**Hedera-Code-Snippets repo
88

99
## Understanding the Upgradeable Proxy Pattern (Simplified)
1010

11-
In traditional smart contracts, you can't change the logic once deployed, which can be risky if you find bugs or want to add new features. The upgradeable proxy pattern solves this by separating your contract into two parts:
11+
In traditional smart contracts, once deployed, the code is immutable, meaning bugs can't be fixed and new features can't be added. The upgradeable proxy pattern solves this by separating the contract into two components:
1212

13-
1. **Proxy Contract**: Stores the state (data) and delegates all calls to the logic contract.
14-
2. **Logic Contract**: Contains the actual business logic and can be replaced or upgraded.
13+
1. **Proxy Contract**: Stores the contract’s state (data) and delegates all function calls to a logic contract using `delegatecall`.
14+
2. **Logic Contract**: Contains the actual business logic and can be upgraded.
1515

1616
When you upgrade your smart contract, you deploy a new logic contract and point your proxy contract to this new logic. The proxy stays at the same address, retaining your data and allowing seamless upgrades.
1717

@@ -31,11 +31,11 @@ When you upgrade your smart contract, you deploy a new logic contract and point
3131

3232
## Table of Contents
3333

34-
1. [Step 1: Set Up Your Project](how-to-upgrade-an-erc-721-token-with-openzeppelin-uups-proxies-and-hardhat-part-3.md#step-1-set-up-your-project)
35-
2. [Step 2: Create Your Initial Upgradeable ERC-721 Contract](how-to-upgrade-an-erc-721-token-with-openzeppelin-uups-proxies-and-hardhat-part-3.md#step-2-create-your-initial-upgradeable-erc-721-contract)
36-
3. [Step 3: Deploy Your Upgradeable Contract](how-to-upgrade-an-erc-721-token-with-openzeppelin-uups-proxies-and-hardhat-part-3.md#step-3-deploy-your-upgradeable-contract)
37-
4. [Step 4: Upgrade Your ERC-721 Contract](how-to-upgrade-an-erc-721-token-with-openzeppelin-uups-proxies-and-hardhat-part-3.md#step-4-upgrade-your-erc-721-contract)
38-
5. [Step 5: Deploy the Upgrade and Verify](how-to-upgrade-an-erc-721-token-with-openzeppelin-uups-proxies-and-hardhat-part-3.md#step-5-deploy-the-upgrade-and-verify)
34+
1. [Set Up Your Project](how-to-upgrade-an-erc-721-token-with-openzeppelin-uups-proxies-and-hardhat-part-3.md#step-1-set-up-your-project)
35+
2. [Create Your Initial Upgradeable ERC-721 Contract](how-to-upgrade-an-erc-721-token-with-openzeppelin-uups-proxies-and-hardhat-part-3.md#step-2-create-your-initial-upgradeable-erc-721-contract)
36+
3. [Deploy Your Upgradeable Contract](how-to-upgrade-an-erc-721-token-with-openzeppelin-uups-proxies-and-hardhat-part-3.md#step-3-deploy-your-upgradeable-contract)
37+
4. [Upgrade Your ERC-721 Contract](how-to-upgrade-an-erc-721-token-with-openzeppelin-uups-proxies-and-hardhat-part-3.md#step-4-upgrade-your-erc-721-contract)
38+
5. [Deploy the Upgrade and Verify](how-to-upgrade-an-erc-721-token-with-openzeppelin-uups-proxies-and-hardhat-part-3.md#step-5-deploy-the-upgrade-and-verify)
3939
6. [Why Use the UUPS Pattern?](how-to-upgrade-an-erc-721-token-with-openzeppelin-uups-proxies-and-hardhat-part-3.md#why-use-the-uups-pattern)
4040

4141
***
@@ -54,9 +54,11 @@ require("@openzeppelin/hardhat-upgrades"); // Plugin for upgradeable contracts
5454
require("@nomicfoundation/hardhat-ethers");
5555
</code></pre>
5656

57+
***
58+
5759
## Step 2: Create Your Initial Upgradeable ERC-721 Contract
5860

59-
Create `erc-721-upgrade.sol` in the `contracts` directory:
61+
Create `erc-721-upgrade.sol` in the `contracts/` directory:
6062

6163
```solidity
6264
// SPDX-License-Identifier: MIT
@@ -107,6 +109,8 @@ Compile the contract:
107109
npx hardhat compile
108110
```
109111

112+
***
113+
110114
## Step 3: Deploy Your Upgradeable Contract
111115

112116
Create `deploy-upgradeable.js` under the `scripts` directory:
@@ -129,7 +133,6 @@ main().catch(console.error);
129133

130134
* **`deployProxy` function**: Deploys the logic contract behind a proxy, calling the initializer function (`initialize`) automatically.
131135
* **`initializer: "initialize"`**: Explicitly specifies which function initializes the contract.
132-
* **`kind: "uups"`**: Specifies using the UUPS proxy pattern.
133136

134137
Deploy your contract:
135138

@@ -144,6 +147,8 @@ npx hardhat run scripts/deploy-upgradeable.js --network testnet
144147
</strong>Upgradeable ERC721 deployed to: 0xb54c97235A7a90004fEb89dDccd68f36066fea8c
145148
</code></pre>
146149

150+
***
151+
147152
## Step 4: Upgrade Your ERC-721 Contract
148153

149154
Let's upgrade your contract by adding a new `version` function. Create `erc-721-upgrade-v2.sol` in your `contracts` folder:
@@ -172,6 +177,8 @@ Compile the upgraded version:
172177
npx hardhat compile
173178
```
174179

180+
***
181+
175182
## Step 5: Deploy the Upgrade and Verify
176183

177184
Create `upgrade.js` script to upgrade and verify the new functionality:
@@ -211,7 +218,7 @@ main().catch(console.error);
211218
```
212219

213220
* **`upgradeProxy`**: Replaces the logic contract behind your existing proxy with the new version.
214-
* **`proxyAddress`**: Points to the proxy contract that manages storage and delegates calls to logic contracts. Upgrading involves replacing the logic without altering the stored data. **Make sure to replace the proxy contract address with the address you've copied.**
221+
* **`proxyAddress`**: Points to the proxy contract that manages storage and delegates calls to logic contracts. Upgrading involves replacing the logic without altering the stored data, since all contract state resides in the proxy, and `delegatecall` ensures the new logic runs in that same storage context. **Make sure to replace the proxy contract address with the address you've copied.**
215222
* **Verification step**: Calls the new `version` method to ensure the upgrade succeeded.
216223

217224
Run this upgrade script:

0 commit comments

Comments
 (0)