3

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.

enter image description here

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.

enter image description here

6
  • What's the token address of your contract? Did you implement the required EIP-165 part? From this comment on the EIP 2981 discussion it seems OpenSea doesn't support the EIP yet.
    – Ismael
    Oct 10, 2021 at 4:10
  • Actually, I was the one who asked that question there. So it seems OpenSea does not support EIP yet... But how do I get a %3 share from people who sell the NFT's I made then? Is there another way for it? Oct 10, 2021 at 14:06
  • The comments says you will have to use OpenSea royalty distribution system, so you have to log into their system and set up it.
    – Ismael
    Oct 10, 2021 at 15:47
  • Isn't there a way to override the transfer function and make it so that I can get %3 of the percentage of every sale? Or isn't this possible? Oct 11, 2021 at 23:13
  • If you are programming the NFT contract you could require an ether fee and revert otherwise. I think most wallet do not support that type of operations on NFTs.
    – Ismael
    Oct 16, 2021 at 18:27

1 Answer 1

1

The royalties set via ERC-2981 is designed to be paid by buyer/seller voluntarily.

It is the job of the marketplace to handle royalty. As far as I know, OpenSea testnet does not support ERC-2981.

Modifying the transfer function is one way to enforce owner/artist fee on each transfer, but there are some problems using this approach.

  • There is no way to detect if a transfer is a trade on some marketplace or just the user transferring token between their own wallets.
  • If, somehow, we detect that a transfer is a trade, then the problem is we do not know the price of the trade in our transfer method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.