I am trying to implement ERC-2981 in a ERC-721A contract. The below code compiles and deploys fine. After a test mint, the transaction overview seems fine:
However, the token tracker shows no transfers, no holders, and indicates an ERC-20 token:
The tokens also do not show up on opensea rinkeby. After setting up default royalties, ERC-2981 shows up correctly on https://royaltyregistry.xyz/, however.
I have tested this contract without ERC-2981 and it works fine without the above problem. I have also tested this contract without ERC-2981 but left the override of the supportsInterface function (only overriding ERC-721A in this case) in there, and it seems to work fine as well.
See https://etherscan.io/address/0x466cfcd0525189b573e794f554b8a751279213ac#code for a similar implementation of a well known project that seems to be working fine.
What's the problem here? Is it just an indexing matter? I am new to coding smart contracts, so forgive me in case the answer is trivial.
Thanks a lot, cheers
Edit: https://rinkeby.etherscan.io/address/0x0a75259419639e20bc85f785682de51689fd717b
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/common/ERC2981.sol";
import "erc721a/contracts/ERC721A.sol";
contract SimpleContract is ERC721A, ERC2981, Ownable, ReentrancyGuard {
uint256 public constant MAX_SUPPLY = 10000;
uint256 public constant MAX_MINTS_WALLET = 1;
string private _baseTokenURI;
bool public isSaleOpen;
mapping (address => uint256) public totalMints;
constructor(string memory tokenData) ERC721A("Simple Contract", "SICO") {
_baseTokenURI = tokenData;
}
function toggleSaleOpen() external onlyOwner {
isSaleOpen = !isSaleOpen;
}
modifier callerIsUser() {
require(tx.origin == msg.sender, "Cannot be called by a contract");
_;
}
function freeMint() external callerIsUser nonReentrant {
require(isSaleOpen, "Sale not open");
require(MAX_SUPPLY > totalSupply(), "Sold out");
require((totalMints[msg.sender]) < MAX_MINTS_WALLET, "Only one free mint per wallet");
_safeMint(msg.sender, 1);
totalMints[msg.sender] += 1;
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function withdraw() external onlyOwner nonReentrant {
(bool success, ) = msg.sender.call{value: address(this).balance}("");
require(success, "Transfer failed");
}
// ERC2981 functions
// @dev Required override
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721A, ERC2981) returns (bool) {
return super.supportsInterface(interfaceId);
}
function setDefaultRoyalty(address receiver, uint96 feeNumerator) external onlyOwner {
_setDefaultRoyalty(receiver, feeNumerator);
}
function deleteDefaultRoyalty() external onlyOwner {
_deleteDefaultRoyalty();
}
}