Replies: 1 comment
-
@soliditee We added the mutex with buyItem function; function buyItem(address nftAddress, uint256 tokenId)
external
payable
isListed(nftAddress, tokenId)
nonReentrant |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The general best practice is to update all state variables before calling external contracts. It was demonstrated in Lesson 15
buyItem()
function as follows:It makes sense to update the state variables first when we reduce the balance of the users, as in the Reentrancy example. However, in the
buyItem()
function above, we are increasing the balance of the seller before calling the NFT contract. Would that make it easier for an attacker to infinitely increase their balance ins_proceeds[listedItem.seller]
with a malicious NFT contract, provided that we forget to implement the mutex?Beta Was this translation helpful? Give feedback.
All reactions