Skip to content

Commit

Permalink
Update solmate-nft.md (#1141)
Browse files Browse the repository at this point in the history
Missing onlyOwner modified is added.
in function withdrawPayments `call` is replaced with `transfer`, because it's safer.
  • Loading branch information
tuncatunc authored Mar 12, 2024
1 parent 7e66d66 commit 1695343
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/tutorials/solmate-nft.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,16 @@ contract NFT is ERC721, Ownable {
}
function withdrawPayments(address payable payee) external onlyOwner {
uint256 balance = address(this).balance;
(bool transferTx, ) = payee.call{value: balance}("");
if (!transferTx) {
if (address(this).balance == 0) {
revert WithdrawTransfer();
}
payable(payee).transfer(address(this).balance);
}
modifier onlyOwner() {
require(msg.sender == owner, "Ownable: caller is not the owner");
_;
}
}
```
Expand Down

0 comments on commit 1695343

Please sign in to comment.