Skip to main content

IRoyalty

Thirdweb's Royalty is a contract extension to be used with any base contract. It exposes functions for setting and reading the recipient of royalty fee and the royalty fee basis points, and lets the inheriting contract perform conditional logic that uses information about royalty fees, if desired. The Royalty contract is ERC2981 compliant.

Methods​

getDefaultRoyaltyInfo​

function getDefaultRoyaltyInfo() external view returns (address, uint16)

Returns the royalty recipient and fee bps.

Returns​

NameTypeDescription
_0addressundefined
_1uint16undefined

getRoyaltyInfoForToken​

function getRoyaltyInfoForToken(uint256 tokenId) external view returns (address, uint16)

Returns the royalty recipient for a particular token Id.

Parameters​

NameTypeDescription
tokenIduint256undefined

Returns​

NameTypeDescription
_0addressundefined
_1uint16undefined

royaltyInfo​

function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount)

Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of exchange. The royalty amount is denominated and should be payed in that same unit of exchange.

Parameters​

NameTypeDescription
tokenIduint256undefined
salePriceuint256undefined

Returns​

NameTypeDescription
receiveraddressundefined
royaltyAmountuint256undefined

setDefaultRoyaltyInfo​

function setDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) external nonpayable

Lets a module admin update the royalty bps and recipient.

Parameters​

NameTypeDescription
_royaltyRecipientaddressundefined
_royaltyBpsuint256undefined

setRoyaltyInfoForToken​

function setRoyaltyInfoForToken(uint256 tokenId, address recipient, uint256 bps) external nonpayable

Lets a module admin set the royalty recipient for a particular token Id.

Parameters​

NameTypeDescription
tokenIduint256undefined
recipientaddressundefined
bpsuint256undefined

supportsInterface​

function supportsInterface(bytes4 interfaceId) external view returns (bool)

Returns true if this contract implements the interface defined by interfaceId. See the corresponding EIP section to learn more about how these ids are created. This function call must use less than 30 000 gas.

Parameters​

NameTypeDescription
interfaceIdbytes4undefined

Returns​

NameTypeDescription
_0boolundefined

Events​

DefaultRoyalty​

event DefaultRoyalty(address indexed newRoyaltyRecipient, uint256 newRoyaltyBps)

Emitted when royalty info is updated.

Parameters​

NameTypeDescription
newRoyaltyRecipient indexedaddressundefined
newRoyaltyBpsuint256undefined

RoyaltyForToken​

event RoyaltyForToken(uint256 indexed tokenId, address indexed royaltyRecipient, uint256 royaltyBps)

Emitted when royalty recipient for tokenId is set

Parameters​

NameTypeDescription
tokenId indexeduint256undefined
royaltyRecipient indexedaddressundefined
royaltyBpsuint256undefined