Skip to main content

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

NameTypeDescription
paramsstruct ConfigurableRoyaltyStandard.RoyaltyParams
_tokenIduint256The NFT asset queried for royalty information
_salePriceuint256The sale price of the NFT asset specified by _tokenId

Return Values

NameTypeDescription
[0]addressreceiver Address that should receive royalties
[1]uint256royaltyAmount 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

NameTypeDescription
paramsstruct ConfigurableRoyaltyStandard.RoyaltyParams
newReceiveraddressThe new address which should receive royalties. See receiver.
newRoyaltyPercentuint256The new percent of salePrice that should be taken for royalties. See royaltyPercent.