-
Notifications
You must be signed in to change notification settings - Fork 0
IggyPostMetadata.sol
The IggyPostMetadata
contract is a smart contract that generates metadata for a Post NFT. It provides functions to retrieve metadata associated with a specific token ID and generate SVG image data for the NFT.
-
tldAddress
(public immutable address): The address of the TLD (Top-Level Domain) contract used to fetch the default names of authors (the.op
domain smart contract address). -
description
(public string): The description of the Post NFT. -
name
(public string): The name of the Post NFT. -
url
(public string): Base URL for a post on Opti Social (https://opti.social/post/
).
The contract emits the following events:
-
DescriptionChanged(address indexed user, string description)
: Fired when the description of the NFT is changed. -
NameChanged(address indexed user, string name)
: Fired when the name of the NFT is changed.
function getMetadata(
uint256 _tokenId,
string calldata _postId,
address _author,
string calldata _textPreview,
uint256 _timestamp
) public view returns (string memory)
Note that the
getMetadata()
function is called by thetokenURI()
function in theIggyPostNft1155
smart contract. So no need to call thegetMetadata()
function directly from the frontend. Always do it through thetokenURI()
function.
This function returns the metadata associated with a specific token ID in the form of a JSON string. It takes the following parameters:
-
_tokenId
: The ID of the token. -
_postId
: The ID of the post associated with the token. -
_author
: The address of the author of the post. -
_textPreview
: The preview text of the post (only the first e.g. 140 chars). -
_timestamp
: The timestamp when the first post NFT of this ID was minted.
Other read functions are for internal contract purposes.
The following functions can only be called by the contract owner.
function changeName(string calldata _name) external onlyOwner
This function allows the contract owner to change the name of the NFT. It takes a new name as a parameter.
function changeDescription(string calldata _description) external onlyOwner
This function allows the contract owner to change the description of the NFT. It takes a new description as a parameter.
function changeUrl(string calldata _url) external onlyOwner
This function allows the contract owner to change the base URL associated with the NFT. It takes a new URL as a parameter.