Trash NFT Contract Documentation
Overview
The Trash contract is an ERC721-based NFT that allows for the minting of NFTs with an accompanying story. It uses a permission system where only authorized ecosystem operators can mint new NFTs or add stories. This contract also provides functionality to manage stories for NFTs and implements access control to ensure that only permitted addresses can perform certain actions.
Inherited Contracts
- ERC721Upgradeable: Provides the functionality of the ERC721 standard.
- StoryInscriptions: Manages stories associated with each token (NFT).
- Permissions: Provides access control, ensuring only authorized roles can mint or manage tokens.
- Initializable: Allows the contract to be initialized with specific values.
Functions
initialize(address _registryAddress)
- Description: Initializes the contract by setting the registry address and setting up the ERC721 token.
- Parameters:
_registryAddress: The address of the registry store that manages permissions.- Reverts:
CantSetZeroAddress: If the provided registry address is the zero address.
mintWithStory(address recipient, string calldata story)
- Description: Mints a new NFT for the recipient with an associated story. Only authorized ecosystem operators can mint tokens.
- Parameters:
recipient: The address of the recipient of the NFT.story: The story associated with the NFT being minted.- Reverts:
InvalidRecipient: If the recipient address is the zero address.StoryIsEmpty: If the provided story is an empty string.- Modifiers:
onlyEcosystemOperator: Ensures that only ecosystem operators can call this function.- Emits:
StoryAdded: Emitted when a new story is added to the minted NFT.
addStory(uint256 tokenId, string calldata story)
- Description: Adds a story to an existing NFT. Only authorized ecosystem operators can add stories.
- Parameters:
tokenId: The ID of the NFT to which the story is being added.story: The story to be added to the NFT.- Modifiers:
onlyEcosystemOperator: Ensures that only ecosystem operators can call this function.- Emits:
StoryAdded: Emitted when a new story is added to the NFT.
getStory(uint256 tokenId)
- Description: Retrieves the story associated with the specified NFT.
- Parameters:
tokenId: The ID of the NFT whose story is being retrieved.- Returns: The story associated with the NFT.
Supporting Abstract Contracts
StoryInscriptions
- Description: Manages the association of stories with NFTs. It includes functionality for adding and retrieving stories.
Functions - StoryInscriptions
-
_addStory(uint256 tokenId, string calldata story): -
Adds a story to the specified NFT. If a story already exists for the token, the transaction will revert.
- Reverts:
StoryAlreadyExists: If the specified token already has a story.
-
Emits:
StoryAdded: Emitted when a story is added to an NFT.
-
_getStory(uint256 tokenId): - Retrieves the story associated with the specified token.
- Returns: The story of the token as a string.
Events
- StoryAdded(uint256 tokenId, string story): Emitted when a story is added to an NFT.
Errors
- CantSetZeroAddress: Thrown when a zero address is provided where a valid address is required.
- NotValidMinter: Thrown when an unauthorized minter attempts to mint an NFT.
- InvalidRecipient: Thrown when the recipient address is the zero address.
- StoryAlreadyExists: Thrown when attempting to add a story to an NFT that already has one.
- StoryIsEmpty: Thrown when attempting to mint or add an empty story to an NFT.
Contract Events
StoryInscriptions Events
Events - StoryInscriptions
- StoryAdded(uint256 tokenId, string story): Emitted when a story is added to an NFT.
Conclusion
The Trash contract provides a secure and controlled way to mint NFTs with accompanying stories. Only authorized ecosystem operators are able to mint and manage NFTs. Each NFT can have a unique story, and once added, the story cannot be changed.