EIP2981TL
Inherits: IEIP2981, ERC165
Author: transientlabs.xyz
Abstract contract to define a default royalty spec while allowing for specific token overrides
Follows EIP-2981 (https://eips.ethereum.org/EIPS/eip-2981)
State Variables
BASIS
uint256 public constant BASIS = 10_000;
_defaultRecipient
address private _defaultRecipient;
_defaultPercentage
uint256 private _defaultPercentage;
_tokenOverrides
mapping(uint256 => RoyaltySpec) private _tokenOverrides;
Functions
constructor
constructor(address defaultRecipient, uint256 defaultPercentage);
Parameters
Name | Type | Description |
---|---|---|
defaultRecipient | address | The default royalty payout address |
defaultPercentage | uint256 | The deafult royalty percentage, out of 10,000 |
_setDefaultRoyaltyInfo
Function to set default royalty info
function _setDefaultRoyaltyInfo(address newRecipient, uint256 newPercentage) internal;
Parameters
Name | Type | Description |
---|---|---|
newRecipient | address | The new default royalty payout address |
newPercentage | uint256 | The new default royalty percentage, out of 10,000 |
_overrideTokenRoyaltyInfo
Function to override royalty spec on a specific token
function _overrideTokenRoyaltyInfo(uint256 tokenId, address newRecipient, uint256 newPercentage) internal;
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The token id to override royalty for |
newRecipient | address | The new royalty payout address |
newPercentage | uint256 | The new royalty percentage, out of 10,000 |
royaltyInfo
ERC165 bytes to add to interface array - set in parent contract implementing this standard bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The NFT asset queried for royalty information |
salePrice | uint256 | The sale price of the NFT asset specified by tokenId |
Returns
Name | Type | Description |
---|---|---|
receiver | address | Address of who should be sent the royalty payment |
royaltyAmount | uint256 | The royalty payment amount for salePrice |
supportsInterface
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165) returns (bool);
getDefaultRoyaltyRecipientAndPercentage
Query the default royalty receiver and percentage.
function getDefaultRoyaltyRecipientAndPercentage() external view returns (address, uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | address | Tuple containing the default royalty recipient and percentage out of 10_000 |
<none> | uint256 |
Events
DefaultRoyaltyUpdate
Event to emit when the default roylaty is updated
event DefaultRoyaltyUpdate(address indexed sender, address newRecipient, uint256 newPercentage);
TokenRoyaltyOverride
Event to emit when a token royalty is overriden
event TokenRoyaltyOverride(
address indexed sender, uint256 indexed tokenId, address newRecipient, uint256 newPercentage
);
Errors
ZeroAddressError
error if the recipient is set to address(0)
error ZeroAddressError();
MaxRoyaltyError
error if the royalty percentage is greater than to 100%
error MaxRoyaltyError();
Structs
RoyaltySpec
struct RoyaltySpec {
address recipient;
uint256 percentage;
}