ConfigurableRoyaltyStandard
ConfigurableRoyaltyStandard
Library to house logic around the ERC2981 royalty standard. Contracts
using this library should define a ConfigurableRoyaltyStandard.RoyaltyParams
state var and public functions that proxy to the logic here. Contracts should
take care to ensure that a public setRoyaltyParams
method is only callable
by an admin.
_INTERFACE_ID_ERC2981
bytes4 _INTERFACE_ID_ERC2981
bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a
_PERCENTAGE_DECIMALS
uint256 _PERCENTAGE_DECIMALS
RoyaltyParams
struct RoyaltyParams {
address receiver;
uint256 royaltyPercent;
}
RoyaltyParamsSet
event RoyaltyParamsSet(address sender, address newReceiver, uint256 newRoyaltyPercent)
royaltyInfo
function royaltyInfo(struct ConfigurableRoyaltyStandard.RoyaltyParams params, uint256 _tokenId, uint256 _salePrice) internal view returns (address, uint256)
Parameters
Name | Type | Description |
---|---|---|
params | struct ConfigurableRoyaltyStandard.RoyaltyParams | |
_tokenId | uint256 | The NFT asset queried for royalty information |
_salePrice | uint256 | The sale price of the NFT asset specified by _tokenId |
Return Values
Name | Type | Description |
---|---|---|
[0] | address | receiver Address that should receive royalties |
[1] | uint256 | royaltyAmount The royalty payment amount for _salePrice |
setRoyaltyParams
function setRoyaltyParams(struct ConfigurableRoyaltyStandard.RoyaltyParams params, address newReceiver, uint256 newRoyaltyPercent) internal
Set royalty params used in royaltyInfo
. The calling contract should limit
public use of this function to owner or using some other access control scheme.
The receiver cannot be the null address
Parameters
Name | Type | Description |
---|---|---|
params | struct ConfigurableRoyaltyStandard.RoyaltyParams | |
newReceiver | address | The new address which should receive royalties. See receiver . |
newRoyaltyPercent | uint256 | The new percent of salePrice that should be taken for royalties. See royaltyPercent . |