Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
114 lines
2.3 KiB
Markdown
114 lines
2.3 KiB
Markdown
# ERC2981
|
|
|
|
Simple ERC2981 NFT Royalty Standard implementation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- customintro:start --><!-- customintro:end -->
|
|
|
|
## Custom Errors
|
|
|
|
### RoyaltyOverflow()
|
|
|
|
```solidity
|
|
error RoyaltyOverflow()
|
|
```
|
|
|
|
The royalty fee numerator exceeds the fee denominator.
|
|
|
|
### RoyaltyReceiverIsZeroAddress()
|
|
|
|
```solidity
|
|
error RoyaltyReceiverIsZeroAddress()
|
|
```
|
|
|
|
The royalty receiver cannot be the zero address.
|
|
|
|
## ERC2981
|
|
|
|
### _feeDenominator()
|
|
|
|
```solidity
|
|
function _feeDenominator() internal pure virtual returns (uint96)
|
|
```
|
|
|
|
Returns the denominator for the royalty amount.
|
|
Defaults to 10000, which represents fees in basis points.
|
|
Override this function to return a custom amount if needed.
|
|
|
|
### supportsInterface(bytes4)
|
|
|
|
```solidity
|
|
function supportsInterface(bytes4 interfaceId)
|
|
public
|
|
view
|
|
virtual
|
|
returns (bool result)
|
|
```
|
|
|
|
Returns true if this contract implements the interface defined by `interfaceId`.
|
|
See: https://eips.ethereum.org/EIPS/eip-165
|
|
This function call must use less than 30000 gas.
|
|
|
|
### royaltyInfo(uint256,uint256)
|
|
|
|
```solidity
|
|
function royaltyInfo(uint256 tokenId, uint256 salePrice)
|
|
public
|
|
view
|
|
virtual
|
|
returns (address receiver, uint256 royaltyAmount)
|
|
```
|
|
|
|
Returns the `receiver` and `royaltyAmount` for `tokenId` sold at `salePrice`.
|
|
|
|
### _setDefaultRoyalty(address,uint96)
|
|
|
|
```solidity
|
|
function _setDefaultRoyalty(address receiver, uint96 feeNumerator)
|
|
internal
|
|
virtual
|
|
```
|
|
|
|
Sets the default royalty `receiver` and `feeNumerator`.
|
|
|
|
<b>Requirements:</b>
|
|
|
|
- `receiver` must not be the zero address.
|
|
- `feeNumerator` must not be greater than the fee denominator.
|
|
|
|
### _deleteDefaultRoyalty()
|
|
|
|
```solidity
|
|
function _deleteDefaultRoyalty() internal virtual
|
|
```
|
|
|
|
Sets the default royalty `receiver` and `feeNumerator` to zero.
|
|
|
|
### _setTokenRoyalty(uint256,address,uint96)
|
|
|
|
```solidity
|
|
function _setTokenRoyalty(
|
|
uint256 tokenId,
|
|
address receiver,
|
|
uint96 feeNumerator
|
|
) internal virtual
|
|
```
|
|
|
|
Sets the royalty `receiver` and `feeNumerator` for `tokenId`.
|
|
|
|
<b>Requirements:</b>
|
|
|
|
- `receiver` must not be the zero address.
|
|
- `feeNumerator` must not be greater than the fee denominator.
|
|
|
|
### _resetTokenRoyalty(uint256)
|
|
|
|
```solidity
|
|
function _resetTokenRoyalty(uint256 tokenId) internal virtual
|
|
```
|
|
|
|
Sets the royalty `receiver` and `feeNumerator` for `tokenId` to zero. |