I have implemented royalty function to my ERC721 NFT smart contract. When I deploy my contract, royalty contract is equal to my address so this way I have defined which address the royalties get transferred.
Secondly, I have set my percentage to 3. Minting cost is 2.50 eth, so whenever people sell their NFT I should get the %3 percentage which equals to 0,075 eth but I don't. I can see that when I call royaltyInfo function in Remix with tokenID, receiver is owner's address and the value is 0,075 eth in wei.
Then I deploy my contract to rinkeby, mint few tokens with another address, sell them to another address on OpenSea but the contract owner's balance does not go up, nor does contract's balance.
There are my codes. By the way, I get that warning but I don't understand how do I place _tokenId there, it gives me error whenever I try to do that.
uint256 public royaltyPerc = 3;
uint256 public cost = 2.50 ether;
address payable public royaltyContract;
bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a;
constructor (
string memory _name,
string memory _symbol,
string memory _initBaseURI
) ERC721(_name, _symbol) {
royaltyContract = payable(msg.sender);
setBaseURI(_initBaseURI);
mint(msg.sender, 1);
}
// public
function mint(address _to, uint256 _mintAmount) public payable {
uint256 supply = totalSupply();
require(!paused);
require(_mintAmount > 0);
require(_mintAmount <= maxMintAmount);
require(supply + _mintAmount <= maxSupply);
for (uint256 i = 1; i <= _mintAmount; i++) {
_safeMint(_to, supply + i);
}
}
function setRoyaltyPercent ( uint256 _perc ) public onlyOwner {
royaltyPerc = _perc;
}
function royaltyInfo( uint256 _tokenId, uint256 _salePrice ) public view returns ( address receiver, uint256 royaltyAmount ) {
receiver = royaltyContract;
royaltyAmount = _salePrice * royaltyPerc / 100;
}
I also tried to find another example to try and see where I'm wrong, but I have no idea where these "recipient" and "value" values from as we don't assign them.