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: pages/lessons/projects/3.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -203,7 +203,7 @@ contract TierNFT is ERC721 {
203
203
204
204
### Adding Tiers and Using Them in the Mint Function
205
205
206
-
Next, to make our code neat and easily readable, just before the contract declaration, add the tiers, and assign their values, where each one represents a service subscription. Note that we assign the `constant` keyword, which is what it sounds like, meaning the values won't change, which also cuts down a lot on gas costs. Always good to know, but we'll go into 'gas optimisation' for you in a future lesson.
206
+
Next, to make our code neat and easily readable, just before the contract declaration add the tier Name and Value state variables, and assign their values, where each one represents a service subscription. Note that we assign the `constant` keyword, which is what it sounds like, meaning the values won't change, which also cuts down a lot on gas costs. Always good to know, but we'll go into 'gas optimisation' for you in a future lesson.
207
207
208
208
```solidity
209
209
// SPDX-License-Identifier: MIT
@@ -269,7 +269,7 @@ Now we need to modify the mint function with logic that can access the three NFT
269
269
270
270
The mint function selects tiers based on the amount of native token it receives stored in `msg.value`.
271
271
272
-
The `require` statement is a simple and powerful function modifier you'll be using a lot in the future, which also helps ensure code we write is 'predictable'. In our case, if we give the function zero token value for TIER_VALUE_0, it will 'revert' with a message telling us, "Not enough value for the minimum Tier", and stop executing. Otherwise we can select the tier we want..... as long as we can afford it!
272
+
The `require` statement is a simple and powerful built-in function of Solidity you'll be using a lot in the future. It checks if the 1st parameter is true or false. On true, it does nothing, allowing execution to continue normally, but on false it throws an exception that reverts everything we modified in the transaction. In our case, if we send the function zero token value, it will 'revert' with a "Not enough value for the minimum Tier" message, and stop executing. Otherwise we can select the tier we want..... as long as we can afford it!
273
273
274
274
We already have two `uint256` variables declared. You might wonder which one is which inside the `tokenTier` mapping? See if you can track through the code and find out - DEFO NEED A QUESTION OR TWO ON THIS - TO GET THAT ANSWER! AND ALSO TO CHECK ON STATE AND LOCAL VARIABLES e.g. `tierId` is declared with `0`.
275
275
@@ -323,7 +323,7 @@ PART 3
323
323
324
324
### Create a (simple) tokenURI function
325
325
326
-
When we inherited Open Zeppelin's ERC721, it gave us a function for `tokenURI` where we can store an image, or a video, or much more. With the help of this ERC721 contract we have the ability to define **a base path** for creating an
326
+
When we inherited Open Zeppelin's ERC721, it gave us a function for `tokenURI` where we can store an image, a video, or much more. With the help of this ERC721 contract we have the ability to define **a base path** for creating a
327
327
unique URI which adds the token ID to the end of it.
0 commit comments