Skip to main content

Royalties

Royalty implements EIP 2981 NFT royalty standard for royalty support on NFT marketplaces, allowing you to take a percentage fee of secondary sales of your NFTs.

Unlocked Features

Once deployed, you can use the features made available by these contracts on the SDK and dashboard:

Implementing the Contract extension

Import the contract extension and make your contract inherit it.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@thirdweb-dev/contracts/extension/Royalty.sol";

contract MyContract is Royalty {

/**
* We store the contract deployer's address only for the purposes of the example
* in the code comment below.
*
* Doing this is not necessary to use the `Royalty` extension.
*/
address public deployer;

constructor() {
deployer = msg.sender;
}

/**
* This function returns who is authorized to set royalty info for your NFT contract.
*
* As an EXAMPLE, we'll only allow the contract deployer to set the royalty info.
*
* You MUST complete the body of this function to use the `Royalty` extension.
*/
function _canSetRoyaltyInfo() internal virtual override returns (bool){
return msg.sender == deployer;
}
}