Skip to content
Lattice

ERC2981Lib

Git Source

Title: ERC2981Lib

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/common/ERC2981.sol)

Library implementing the ERC-2981 NFT Royalty Standard.

Mirrors OpenZeppelin v5.6.1 ERC2981 logic. All state lives in an ERC-7201 slot.

Functions

erc2981Storage

function erc2981Storage() internal pure returns (ERC2981Storage storage $);

Returns

NameTypeDescription
$ERC2981Storage

__ERC2981_init

Initializes the ERC-2981 module and registers the interface.

Must be called inside a pre/postInitializer block.

function __ERC2981_init() internal;

registerInterface

Registers support for the IERC2981 interface via ERC-165.

function registerInterface() internal;

_feeDenominator

Returns the royalty denominator (basis points: 10_000).

function _feeDenominator() internal pure returns (uint96);

Returns

NameTypeDescription
<none>uint96

royaltyInfo

Returns royalty information for a given token sale.

Uses token-specific royalty if set, otherwise falls back to default.

function royaltyInfo(uint256 tokenId, uint256 salePrice) internal view returns (address, uint256);

Parameters

NameTypeDescription
tokenIduint256
salePriceuint256

Returns

NameTypeDescription
<none>address
<none>uint256

setDefaultRoyalty

Sets the default royalty receiver and fraction. Admin-only.

function setDefaultRoyalty(address receiver, uint96 feeNumerator) internal;

Parameters

NameTypeDescription
receiveraddress
feeNumeratoruint96

deleteDefaultRoyalty

Deletes the default royalty configuration. Admin-only.

function deleteDefaultRoyalty() internal;

setTokenRoyalty

Sets a per-token royalty override. Admin-only.

function setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal;

Parameters

NameTypeDescription
tokenIduint256
receiveraddress
feeNumeratoruint96

resetTokenRoyalty

Removes the per-token royalty override, falling back to default. Admin-only.

function resetTokenRoyalty(uint256 tokenId) internal;

Parameters

NameTypeDescription
tokenIduint256

_setDefaultRoyalty

Sets the default royalty receiver and fraction. Reverts if invalid.

function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal;

Parameters

NameTypeDescription
receiveraddress
feeNumeratoruint96

_deleteDefaultRoyalty

Deletes the default royalty configuration.

function _deleteDefaultRoyalty() internal;

_setTokenRoyalty

Sets a per-token royalty override. Reverts if invalid.

function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal;

Parameters

NameTypeDescription
tokenIduint256
receiveraddress
feeNumeratoruint96

_resetTokenRoyalty

Removes the per-token royalty override, falling back to default.

function _resetTokenRoyalty(uint256 tokenId) internal;

Parameters

NameTypeDescription
tokenIduint256