CuttingBoardNFT
Inherits: ERC721, Owned
Title: CuttingBoardNFT
NFT representing temporary control rights over a validator's cutting board
Each NFT grants the holder the ability to update the reward allocation (cutting board) for a specific validator until the expiry timestamp. NFTs are tradeable and can be used in DeFi protocols as collateral or for yield optimization strategies.
State Variables
auction
Address of the auction contract authorized to mint NFTs
address public immutable auction
manager
Address of the control manager authorized to invalidate NFTs
address public manager
_tokenRights
Mapping from token ID to control rights
mapping(uint256 => ControlRights) private _tokenRights
_nextTokenId
Current token ID counter
uint256 private _nextTokenId
_baseTokenURI
Metadata uri
string private _baseTokenURI
Functions
onlyAuction
modifier onlyAuction() ;
onlyManager
modifier onlyManager() ;
constructor
Initialize the CuttingBoardNFT contract
constructor(
address _auction,
address _owner,
address _manager,
string memory _baseURI
) ERC721("Cutting Board NFT", "CBNFT") Owned(_owner);
Parameters
| Name | Type | Description |
|---|---|---|
_auction | address | Address of the auction contract |
_owner | address | Address of the contract owner |
_manager | address | Address of contract manager for invalidating NFT's |
_baseURI | string | Metadata uri |
setManager
Set the manager contract address
function setManager(address _manager) external virtual onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
_manager | address | Address of the ValidatorControlManager contract |
mint
Mint a new control NFT
function mint(
address to,
bytes calldata validatorPubkey,
uint256 expiryTimestamp,
uint256 auctionId
) external virtual onlyAuction returns (uint256 tokenId);
Parameters
| Name | Type | Description |
|---|---|---|
to | address | Address to receive the NFT |
validatorPubkey | bytes | Validator pubkey being controlled |
expiryTimestamp | uint256 | When control rights expire |
auctionId | uint256 | The auction ID that granted these rights |
Returns
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The ID of the newly minted token |
isValid
Check if an NFT is still valid (active and not expired)
function isValid(uint256 tokenId) external view virtual returns (bool);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The token ID to check |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if the NFT is valid and grants control rights |
getValidator
Get the validator pubkey associated with a token
function getValidator(uint256 tokenId)
external
view
virtual
returns (bytes memory);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The token ID |
Returns
| Name | Type | Description |
|---|---|---|
<none> | bytes | The validator pubkey |
getControlRights
Get complete control rights information for a token
function getControlRights(uint256 tokenId)
external
view
virtual
returns (
bytes memory validatorPubkey,
uint256 expiryTimestamp,
uint256 auctionId,
bool active
);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The token ID |
Returns
| Name | Type | Description |
|---|---|---|
validatorPubkey | bytes | The validator pubkey |
expiryTimestamp | uint256 | When control expires |
auctionId | uint256 | The auction that granted these rights |
active | bool | Whether the NFT is still active |
invalidate
Invalidate an NFT (emergency or on expiry)
function invalidate(uint256 tokenId) external virtual onlyManager;
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The token ID to invalidate |
tokenURI
Get the token URI for metadata
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The token ID |
Returns
| Name | Type | Description |
|---|---|---|
<none> | string | The token URI (empty string for now, can be extended) |
setBaseURI
Set metadata uri
Only owner can call
function setBaseURI(string memory newBaseURI) external onlyOwner;
Parameters
| Name | Type | Description |
|---|---|---|
newBaseURI | string | new uri |
totalSupply
Get the total number of NFTs minted
function totalSupply() external view virtual returns (uint256);
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The total supply of NFTs |
Events
ControlNFTMinted
Emitted when a new control NFT is minted
event ControlNFTMinted(
uint256 indexed tokenId,
address indexed owner,
bytes validatorPubkey,
uint256 expiryTimestamp,
uint256 indexed auctionId
);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The ID of the newly minted token |
owner | address | The address receiving the NFT |
validatorPubkey | bytes | The validator pubkey being controlled |
expiryTimestamp | uint256 | When control rights expire |
auctionId | uint256 | The auction ID that granted these rights |
ControlNFTInvalidated
Emitted when an NFT is invalidated
event ControlNFTInvalidated(uint256 indexed tokenId);
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The ID of the invalidated token |
ManagerUpdated
Emitted when the manager address is updated
event ManagerUpdated(
address indexed oldManager, address indexed newManager
);
Parameters
| Name | Type | Description |
|---|---|---|
oldManager | address | The previous manager address |
newManager | address | The new manager address |
Errors
NotAuction
Thrown when caller is not the auction contract
error NotAuction();
NotManager
Thrown when caller is not the manager contract
error NotManager();
InvalidTokenId
Thrown when attempting to interact with an invalid token ID
error InvalidTokenId();
TokenInactive
Thrown when attempting to interact with an inactive NFT
error TokenInactive();
TokenExpired
Thrown when attempting to interact with an expired NFT
error TokenExpired();
InvalidManager
Thrown when providing an invalid manager address
error InvalidManager();
Structs
ControlRights
Represents the control rights associated with an NFT
struct ControlRights {
bytes validatorPubkey;
uint256 expiryTimestamp;
uint256 auctionId;
bool active;
}