You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/smart-contracts/how-to-mint-and-burn-an-erc-721-token-using-hardhat-and-ethers-part-1.md
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,8 @@ You can take a look at the **complete code** in the [**Hedera-Code-Snippets repo
31
31
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)
32
32
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)
33
33
34
+
***
35
+
34
36
## Step 1: Project Setup
35
37
36
38
#### Initialize Project 
@@ -319,6 +321,8 @@ npx hardhat run scripts/burn.js --network testnet
319
321
320
322
**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)**!**
Copy file name to clipboardExpand all lines: tutorials/smart-contracts/how-to-set-access-control-a-token-uri-pause-and-transfer-an-erc-721-token-using-hardhat-part-2.md
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -114,6 +114,8 @@ Compile your new contract:
114
114
npx hardhat compile
115
115
```
116
116
117
+
***
118
+
117
119
## Step 2: Deploying the Smart Contract and Minting a Token
118
120
119
121
Create `deploy-advanced.js` in your `scripts` folder:
Copy file name to clipboardExpand all lines: tutorials/smart-contracts/how-to-upgrade-an-erc-721-token-with-openzeppelin-uups-proxies-and-hardhat-part-3.md
+18-11Lines changed: 18 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -8,10 +8,10 @@ You can take a look at the **complete code** in the [**Hedera-Code-Snippets repo
8
8
9
9
## Understanding the Upgradeable Proxy Pattern (Simplified)
10
10
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:
12
12
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.
15
15
16
16
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.
17
17
@@ -31,11 +31,11 @@ When you upgrade your smart contract, you deploy a new logic contract and point
31
31
32
32
## Table of Contents
33
33
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)
39
39
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)
40
40
41
41
***
@@ -54,9 +54,11 @@ require("@openzeppelin/hardhat-upgrades"); // Plugin for upgradeable contracts
54
54
require("@nomicfoundation/hardhat-ethers");
55
55
</code></pre>
56
56
57
+
***
58
+
57
59
## Step 2: Create Your Initial Upgradeable ERC-721 Contract
58
60
59
-
Create `erc-721-upgrade.sol` in the `contracts` directory:
61
+
Create `erc-721-upgrade.sol` in the `contracts/` directory:
60
62
61
63
```solidity
62
64
// SPDX-License-Identifier: MIT
@@ -107,6 +109,8 @@ Compile the contract:
107
109
npx hardhat compile
108
110
```
109
111
112
+
***
113
+
110
114
## Step 3: Deploy Your Upgradeable Contract
111
115
112
116
Create `deploy-upgradeable.js` under the `scripts` directory:
@@ -129,7 +133,6 @@ main().catch(console.error);
129
133
130
134
***`deployProxy` function**: Deploys the logic contract behind a proxy, calling the initializer function (`initialize`) automatically.
131
135
***`initializer: "initialize"`**: Explicitly specifies which function initializes the contract.
132
-
***`kind: "uups"`**: Specifies using the UUPS proxy pattern.
133
136
134
137
Deploy your contract:
135
138
@@ -144,6 +147,8 @@ npx hardhat run scripts/deploy-upgradeable.js --network testnet
144
147
</strong>Upgradeable ERC721 deployed to: 0xb54c97235A7a90004fEb89dDccd68f36066fea8c
145
148
</code></pre>
146
149
150
+
***
151
+
147
152
## Step 4: Upgrade Your ERC-721 Contract
148
153
149
154
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:
172
177
npx hardhat compile
173
178
```
174
179
180
+
***
181
+
175
182
## Step 5: Deploy the Upgrade and Verify
176
183
177
184
Create `upgrade.js` script to upgrade and verify the new functionality:
@@ -211,7 +218,7 @@ main().catch(console.error);
211
218
```
212
219
213
220
***`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.**
215
222
***Verification step**: Calls the new `version` method to ensure the upgrade succeeded.
0 commit comments