Web3 Unleashed Rental Marketplace issue-- ParserError: Expected '{' but got reserved keyword 'override' #5715
-
Thank you for the wonderful web series, Web3 unleashed! I've been enjoying the videos. I'm following the guide, Web3 Unleashed: Write a Rentable NFT Smart Contract. I'm trying to implement a NFT rental marketplace, and I've encountered a problem while following the tutorial.
Not really sure what to do about this. I think I'll start from scratch and see if I missed anything in the tutorial, then report back. EDIT: I found the the source repo for the nft rental marketplace guide and cloned it. Now I can rule out any faulty copy-pasting on my end. I ran
Research time! I will look into these errors. EDIT2: The first error is I looked up the source for the two classes(?) that our ERC4907 extends. That's ERC721URIStorage, and IERC4907. _beforeTokenTransfer isn't part of ERC721URIStorage.sol, so it must be part of IERC4907.sol. Here is that file, with comments omitted to save space // IERC4907.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;
interface IERC4907 {
event UpdateUser(uint256 indexed tokenId, address indexed user, uint64 expires);
function setUser(uint256 tokenId, address user, uint64 expires) external;
function userOf(uint256 tokenId) external view returns(address);
function userExpires(uint256 tokenId) external view returns(uint256);
} There is no // ERC731URIStorage.sol
abstract contract ERC721URIStorage is ERC721 {...} The second error is I looked at ERC721 and saw how _beforeTokenTransfer is defined function _beforeTokenTransfer(
address from,
address to,
uint256, /* firstTokenId */
uint256 batchSize
) internal virtual {
if (batchSize > 1) {
if (from != address(0)) {
_balances[from] -= batchSize;
}
if (to != address(0)) {
_balances[to] += batchSize;
}
}
} There are indeed 4 parameters. I don't understand why Well, I understand the errors now, but I'm not sure how to fix them. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I think I figured it out. There was a breaking change in _beforeTokenTransfer about 9 days ago which requires _beforeTokenTransfer to have a fourth parameter. Here's what my _beforeTokenTransfer function looks like now, and this was able to deploy without an error. function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId,
uint256 /** batch **/
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId, 1);
if (from != to && _users[tokenId].user != address(0)) {
delete _users[tokenId];
emit UpdateUser(tokenId, address(0), 0);
}
} Looks like the guide uses openzeppelin 4.7.3, and yarn installed 4.8.0. EDIT: Forgot to mention that I solved the |
Beta Was this translation helpful? Give feedback.
I think I figured it out. There was a breaking change in _beforeTokenTransfer about 9 days ago which requires _beforeTokenTransfer to have a fourth parameter.
Here's what my _beforeTokenTransfer function looks like now, and this was able to deploy without an error.
Looks like the guide uses openzeppelin 4.7.3, and yarn installed 4.8.0.
EDIT: Forgot…