Last active
November 4, 2022 11:35
-
-
Save cygaar/b3397a515206710089eeef40ec43a85b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.8.4; | |
import "erc721a/contracts/ERC721A.sol"; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
import "@openzeppelin/contracts/token/common/ERC2981.sol"; | |
contract ERC721AMock is Ownable, ERC2981, ERC721A { | |
mapping(uint256 => uint256) private royaltyOverrides; | |
constructor(string memory name_, string memory symbol_) ERC721A(name_, symbol_) {} | |
function mint(address to, uint256 quantity) public { | |
_mint(to, quantity); | |
} | |
function royaltyInfo(uint256 _tokenId, uint256 _salePrice) public view virtual override returns (address, uint256) { | |
(address receiver, uint256 royaltyAmount) = ERC2981.royaltyInfo(_tokenId, _salePrice); | |
// Use override amount if present | |
if (royaltyOverrides[_tokenId] != 0) { | |
royaltyAmount = royaltyOverrides[_tokenId]; | |
} | |
return (receiver, royaltyAmount); | |
} | |
function setRoyaltyOverride(uint256 _tokenId, uint256 _amount) external onlyOwner { | |
royaltyOverrides[_tokenId] = _amount; | |
} | |
function supportsInterface( | |
bytes4 interfaceId | |
) public view virtual override(ERC721A, ERC2981) returns (bool) { | |
return | |
ERC721A.supportsInterface(interfaceId) || | |
ERC2981.supportsInterface(interfaceId); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment