Royalty
Royalty implements EIP-2981 NFT royalty standard for royalty
support on NFT marketplaces, allowing you to take a percentage fee of secondary sales of your NFTs.
View on GitHub
The Royalty extension is an abstract contract, and expects you to implement the following functions by yourself:
| Name | Type | Returns | Description | 
|---|---|---|---|
| _canSetRoyaltyInfo | internal view virtual | bool | Runs on every attempt to set a new royalty recipient or BPS. Returns whether this info can be set in the given execution context. | 
This is an example smart contract demonstrating how to inherit from this extension and override the functions to add (optional) custom functionality.
All NFT contracts (ERC721 or ERC1155) implement this extension.
- Returns royalty recipient and amount for a given NFT and its sale price.
- Parameter tokenId: The tokenID of the NFT for which to query royalty info.
- Parameter salePrice: Sale price of the NFT.
- Returns the royalty recipient and BPS for a given NFT.
- Parameter tokenId: The tokenID of the NFT for which to query royalty info.
- Returns the default royalty recipient and BPS for the contract's NFTs.
- Lets an authorized wallet set the default royalty recipient and BPS for the contract's NFT.
- Parameter royaltyRecipient: The address to set as the new default royalty recipient.
- Parameter royaltyBps: The value to set as the new default royalty BPS.
- The _canSetRoyaltyInfofunction is run on every call to this function. If the return value of_canSetRoyaltyInfoisfalse, thesetDefaultRoyaltyInfocall will revert.
- Lets an authorized wallet set the royalty recipient and BPS for a particular NFT of the contract.
- Parameter tokenId: The tokenId of the NFT for which to set royalty info.
- Parameter recipient: The address to set as the new royalty recipient for the NFT.
- Parameter bps: The value to set as the new royalty BPS for the NFT.
- The _canSetRoyaltyInfofunction is run on every call to this function. If the return value of_canSetRoyaltyInfoisfalse, thesetRoyaltyInfoForTokencall will revert.
- Sets the default royalty recipient and BPS for the contract's NFT.
- Parameter royaltyRecipient: The address to set as the new default royalty recipient.
- Parameter royaltyBps: The value to set as the new default royalty BPS.
- The _canSetRoyaltyInfofunction is not run on a call to this function.
- Sets the royalty recipient and BPS for a particular NFT of the contract.
- Parameter tokenId: The tokenId of the NFT for which to set royalty info.
- Parameter recipient: The address to set as the new royalty recipient for the NFT.
- Parameter bps: The value to set as the new royalty BPS for the NFT.
- The _canSetRoyaltyInfofunction is not run on a call to this function.
- Runs on every setDefaultRoyaltyInfoandsetRoyaltyInfoForTokenfunction calls.
- Returns whether the relevant royalty info can be set in the given execution context.
- For example, this function can check whether the wallet calling setDefaultRoyaltyInfois the contract owner, and enforce that only the owner should be able to successfully callsetDefaultRoyaltyInfo.