Skip to main content

Collections — Royalty

When your NFTs are sold on marketplaces, the marketplace can take a percentage cut as secondary-sales fee for the creators. At this point in time there various royalty solutions, and marketplaces use different ways to configure royalty percentage and royalty receiver.

Flair provides a royalty extension that cover majority of marketplaces (including OpenSea, Rarible, LooksRare, and any marketplace which supports ERC2981).

Dashboard

Easiest way to configure your on-chain royalty is via Dashboard.

Recommended

Using dashboard is the preferred approach for management operations, as it's a one-time operation and it is not a good investment to work with React hooks or REST APIs if you only plan to launch one or two collections.

React Hooks

Alternatively you can manage royalties using hooks exported in flair-sdk.

useDefaultRoyalty

Get current default royalty config. This hook returns receiver and percent, and bps

import { useDefaultRoyalty } from "flair-sdk";

const App = () => {
const { data, error, isLoading } = useDefaultRoyalty({
contractAddress: "0x123412341234123412341234123412341234",
enabled: true, // (optional) Initial attempt to read, defaults to true.
watch: false, // (optional) Check the value on each new block, defaults false.
});

return (
<div>
Royalty: {data.percent}% Receiver: {data.receiver}
</div>
);
};

useDefaultRoyaltyUpdater

Update default royalty's percentage and receiver wallet address.

import { useDefaultRoyaltyUpdater } from "flair-sdk";

const App = () => {
const {
error,
isLoading,
writeAndWait: updateDefaultRoyalty,
} = useDefaultRoyaltyUpdater({
contractAddress: "0x123412341234123412341234123412341234",
});

return (
<button
onClick={() =>
// Note this contract function accepts a struct, therefore array-in-array [[...]] syntax below.
updateDefaultRoyalty([
[
"0x22222333333444444445555566655", // new receiver wallet
Number("4.5") * 100, // must be in basis points: 4.5% -> 450
],
])
}
>
Update Now
</button>
);
};

Solidity Extensions

ERC721RoyaltyExtension.sol

A ready-made solidity extension to add on-chain royalty capabilities to your NFT collection.

This extension includes these features out-of-box:

View source code.

info

OpenSea uses off-chain configuration for royalty (within collection metadata). Flair contract deployment automatically puts your initial royalty config in the metadata, so you don't need to do anything.