contract boreape is ERC721, Ownable {
using Counters for Counters.Counter;
using Strings for uint256;
Counters.Counter private _tokenIds;
uint256 public constant MAX_SUPPLY = 10;
uint256 public constant MAX_PER_WALLET = 5;
string public uriPrefix = "ipfs://b--------------------q/";
string public uriSuffix = ".json";
mapping(address => uint256) public tokenCount;
constructor() ERC721("Bored Ape ", "BAYC") {}
function mint(address to, uint256 amount) public {
require(amount > 0, "Amount cannot be zero");
require(tokenCount[to] + amount <= MAX_PER_WALLET, "Exceeds maximum tokens per wallet");
require(_tokenIds.current() + amount <= MAX_SUPPLY, "Exceeds maximum supply");
for (uint256 i = 0; i < amount; i++) {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_mint(to, newItemId);
tokenCount[to]++;
}
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), uriSuffix))
: "";
}
function _baseURI() internal view virtual override returns (string memory) {
return uriPrefix;
}
function totalSupply() public view returns (uint256) {
return _tokenIds.current();
}
}
I am facing issue if i am using the imports without the github
Is there any other way to set the tokenUri without the suffix and prefix pls guide me
Pls tell me what all imports i need to do then and how i should set the baseuri
and if i replace the import statement with these kind of imports
import "[@openzeppelin/contracts/token/ERC721/ERC721.sol];
import "[@openzeppelin/contracts/access/Ownable.sol];
then i get this error
{DeclarationError: Undeclared identifier.
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
| ^^^^^^^
and if i replace the import statement with these kind of imports
import "[@openzeppelin/contracts/token/ERC721/ERC721.sol];
import "[@openzeppelin/contracts/access/Ownable.sol];
then i get this error
{DeclarationError: Undeclared identifier.
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
| ^^^^^^^
DeclarationError: Undeclared identifier.
--> contracts/Tiar.sol:54:17:
|
54 | require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
| ^^^^^^^ then i get this error
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
but at the time of verifying on etherscan . This error is shown
Compiler debug log:
Error! Unable to generate Contract Bytecode and ABI (General Exception, unable to get compiled [bytecode])
For troubleshooting, you can try compiling your source code with the Remix - Solidity IDE and check for exceptions