English 中文(简体)
Undeclared identifier : _requireOwned(tokenId) error
原标题:

I am getting below error while running the smart contract:

DeclarationError: Undeclared identifier. --> @openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol:35:9: | 35 | _requireOwned(tokenId); | ^^^^^^^^^^^^^

Smart contract code:

//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";

contract RealEstate is ERC721URIStorage {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor() ERC721("Real Estate", "REAL") {}

    function mint(string memory tokenURI) public returns (uint256) {
        _tokenIds.increment();

        uint256 newItemId = _tokenIds.current();
        _mint(msg.sender, newItemId);
        _setTokenURI(newItemId, tokenURI);

        return newItemId;
    }

    function totalSupply() public view returns (uint256) {
        return _tokenIds.current();
    }
}

I tried removing the _requireOwned(tokenId); from ERC721URIStorage.sol but still getting the error.

Any help would be appreciated.

I tried removing the _requireOwned(tokenId); from ERC721URIStorage.sol but still getting the error.

Also tried adding the _requireOwned(tokenId) into my smart contract but it s throwing same error.

问题回答

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/extensions/ERC721URIStorage.sol";




相关问题
ERC20 津贴不足

我非常经常地问这个问题。 我道歉,但我不理解许多答案。 我曾试图订立一项契约,但这一错误使我陷入了境地。 ......

Web3.js sendSignedTransaction Problem...... plz help me

i use ganache-cli for operate node in local environment. after that I wrote Smart contract solidity code in remix. And then, deployed in my ganache node. And deployed log was successful in my ganache. ...

unable to get data from blockchain using thirdweb

I am building a simple crowdfunding app using React and thirdweb , I was able to successfully create a Campaign mean data is pushed successfully , I have read docs everything works fine , but when i ...

false Transaction mined but execution failed in Remix IDE

I am getting false Transaction mined but execution failed error from the constructor function in the contract. I am just saving the address from which the contract is deployed in manager variable and ...

TypeError: (0 , ethers_1.getAddress) is not a function

I am getting this error while deploying my smart contract const main = async() => { const contractFactory = await ethers.getContractFactory( TwitterContract ); const contract = await ...

ETH sendSignedTransaction

I Try to use @ethereumjs/tx to sign Transaction. I want to send ETH from one address to second address. .... const legacy = require( @ethereumjs/tx/dist/legacyTransaction ); const utils = require( ...

热门标签