Royalty

Royalty

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 defualt royalty recipient and BPS for this contract's NFTs.

Returns

Name
Type
Description

_0

address

undefined

_1

uint16

undefined

getRoyaltyInfoForToken

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

View royalty info for a given token.

Returns royalty recipient and bps for _tokenId.

Parameters

Name
Type
Description

_tokenId

uint256

The tokenID of the NFT for which to query royalty info.

Returns

Name
Type
Description

_0

address

undefined

_1

uint16

undefined

royaltyInfo

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

View royalty info for a given token and sale price.

Returns royalty amount and recipient for tokenId and salePrice.

Parameters

Name
Type
Description

tokenId

uint256

The tokenID of the NFT for which to query royalty info.

salePrice

uint256

Sale price of the token.

Returns

Name
Type
Description

receiver

address

Address of royalty recipient account.

royaltyAmount

uint256

Royalty amount calculated at current royaltyBps value.

setDefaultRoyaltyInfo

function setDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) external nonpayable

Updates default royalty recipient and bps.

Caller should be authorized to set royalty info. See {_canSetRoyaltyInfo}. Emits {DefaultRoyalty Event}; See {_setupDefaultRoyaltyInfo}.

Parameters

Name
Type
Description

_royaltyRecipient

address

Address to be set as default royalty recipient.

_royaltyBps

uint256

Updated royalty bps.

setRoyaltyInfoForToken

function setRoyaltyInfoForToken(uint256 _tokenId, address _recipient, uint256 _bps) external nonpayable

Updates default royalty recipient and bps for a particular token.

Sets royalty info for _tokenId. Caller should be authorized to set royalty info. See {_canSetRoyaltyInfo}. Emits {RoyaltyForToken Event}; See {_setupRoyaltyInfoForToken}.

Parameters

Name
Type
Description

_tokenId

uint256

undefined

_recipient

address

Address to be set as royalty recipient for given token Id.

_bps

uint256

Updated royalty bps for the token Id.

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

Name
Type
Description

interfaceId

bytes4

undefined

Returns

Name
Type
Description

_0

bool

undefined

Events

DefaultRoyalty

event DefaultRoyalty(address indexed newRoyaltyRecipient, uint256 newRoyaltyBps)

Parameters

Name
Type
Description

newRoyaltyRecipient indexed

address

undefined

newRoyaltyBps

uint256

undefined

RoyaltyForToken

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

Parameters

Name
Type
Description

tokenId indexed

uint256

undefined

royaltyRecipient indexed

address

undefined

royaltyBps

uint256

undefined

Last updated