Setting Royalty for NFTs

Hi all,
I have some questions regarding the ERC721 token smart contract with OPenZeppelin.

  1. Can anybody tell me how to set royalty (say 5%) for NFT collections in smart contract?
    If I put the smart contract in marketplaces such as Opensea, then it is easy to set royalty.
    But how can I set it in smart contract so that people minting directly from etherscan also have to pay the royalty fee?

  2. Is it a good idea to make whitelistUser() function open to all, or should I make it onlyOwner?

  3. Is there any way to do lazy minting?

Yes you can perform lazy minting by changing the mint function from onlyowner to payable

You should make your whitelist users onlyowner

For royalty payments you can check this eip
https://eips.ethereum.org/EIPS/eip-2981

1 Like

Hi,
Thank you for the answers. Does making the minting function’payable’ allows me to mint without prior gas fees?

Can you expand on this so that I can be sure I understand what you mean? Would you like to mint a specified amount of tokens during contract deployment?

Yes.
Because I want to deploy the contract to a marketplace (say Opensea).
Without a single minted token I do not think it is possible to 'get listed' in Opensea.

Please correct me if I am wrong, or if there is any better approarch.

You want let your buyers pay for minting the token

please check opensea contract source code in github