Hello there,
Thank you in advance for helping me, I'm getting a revert error in mintLand function which isn't the case because according to docs the contract deployer will be granted [DEFAULT_ADMIN/MINTER/PAUSER] roles.
I tried setting up the roles in the constructor, even though it didn't make sense to me but I'm still getting the same error. Would you kindly advise with what I'm missing/misunderstand here?
Here is a hypothetical scenario of my code:
// SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.6;
import "@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
contract MarsToken is ERC721PresetMinterPauserAutoId {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
address public owner = msg.sender;
struct Land{
string landURI;
uint256 initialPrice;
}
mapping(uint256 => Land) public landbyTokenId;
constructor() ERC721PresetMinterPauserAutoId("MarsToken", "MARS", "https://mars.nasa.gov/") {}
modifier landRegistered(uint tokenId) {
require(_exists(tokenId), "MarsAuction: Land isn't registered!");
_;
}
function mintLand(string memory _landURI, uint256 price) public returns(uint) {
require(hasRole("MINTER_ROLE", msg.sender), "MarsToken: Not Authorized to mint");
_tokenIds.increment();
uint tokenId = _tokenIds.current();
_mint(owner, tokenId);
landbyTokenId[tokenId] = Land(_landURI, price);
return tokenId;
}
Environment
truffle / Remix