SettlementNft
Inherits: ERC721
Author: EridianAlpha
An ERC721 NFT token called Ethereum Settlement
(SETTLEMENT).
State Variables
BASE_IMAGE_URI
string public BASE_IMAGE_URI;
SETTLER_TOKEN
SettlerToken public immutable SETTLER_TOKEN;
nextTokenId
uint256 public nextTokenId = 1;
s_mintTimestamp
mapping(uint256 => uint256) internal s_mintTimestamp;
s_ownerToId
mapping(address => uint256) internal s_ownerToId;
Functions
constructor
Constructor to initialize the contract with a base image URI and deploy the SettlerToken contract.
constructor(string memory _baseImageUri) ERC721("Ethereum Settlement", "SETTLEMENT");
Parameters
Name | Type | Description |
---|---|---|
_baseImageUri | string | The base URI for the NFT image. |
_update
Override standard ERC721 _update
function.
Mints outstanding SETTLER tokens. Checks only 1 NFT per address.
function _update(address to, uint256 tokenId, address auth) internal override returns (address previousOwner);
Parameters
Name | Type | Description |
---|---|---|
to | address | The address to transfer the NFT to. |
tokenId | uint256 | The ID of the NFT. |
auth | address | The address that is authorized to transfer the NFT. |
Returns
Name | Type | Description |
---|---|---|
previousOwner | address | The previous owner of the NFT. |
mint
Override standard ERC721 mint
function.
Mints a new NFT and sets the mint timestamp. Adds the msg.sender to the s_ownerToId mapping.
function mint() external;
tokenURI
Override standard ERC721 tokenURI
function.
Generates the JSON metadata for the NFT.
function tokenURI(uint256 tokenId) public view override returns (string memory uri);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the NFT. |
Returns
Name | Type | Description |
---|---|---|
uri | string | The JSON metadata for the NFT. |
_generateAttributes
Generates the attributes for the NFT used in the tokenURI.
function _generateAttributes(uint256 tokenId) internal view returns (string memory attributes);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the NFT. |
Returns
Name | Type | Description |
---|---|---|
attributes | string | The attributes for the NFT. |
_generateSvg
Generates the SVG for the NFT.
function _generateSvg(uint256 tokenId) internal view returns (string memory svg);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the NFT. |
Returns
Name | Type | Description |
---|---|---|
svg | string | The SVG for the NFT. |
_generateSettlementRectangle
Generates the SVG rectangle for the settlement ID.
function _generateSettlementRectangle(string memory tokenIdString) internal pure returns (string memory rectangleSvg);
Parameters
Name | Type | Description |
---|---|---|
tokenIdString | string | The ID of the NFT as a string. |
Returns
Name | Type | Description |
---|---|---|
rectangleSvg | string | The SVG rectangle for the settlement ID. |
_generateDaysSinceMintRectangle
Generates the SVG rectangle for the days since mint.
function _generateDaysSinceMintRectangle(uint256 tokenId) internal view returns (string memory rectangleSvg);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the NFT. |
Returns
Name | Type | Description |
---|---|---|
rectangleSvg | string | The SVG rectangle for the days since mint. |
_daysSinceMint
Calculates the days since mint for an NFT.
function _daysSinceMint(uint256 _mintTimestamp) internal view returns (uint256 daysSinceMint);
Parameters
Name | Type | Description |
---|---|---|
_mintTimestamp | uint256 | The timestamp when the NFT was minted. |
Returns
Name | Type | Description |
---|---|---|
daysSinceMint | uint256 | The days since the NFT was minted. |
getOwnerToId
Getter function to get the NFT ID from an owner address.
function getOwnerToId(address owner) external view returns (uint256 tokenId);
Parameters
Name | Type | Description |
---|---|---|
owner | address | The address of the NFT owner. |
Returns
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the NFT. |
getMintTimestamp
Getter function to get the mint timestamp of an NFT from a token ID.
function getMintTimestamp(uint256 tokenId) external view returns (uint256 mintTimestamp);
Parameters
Name | Type | Description |
---|---|---|
tokenId | uint256 | The ID of the NFT. |
Returns
Name | Type | Description |
---|---|---|
mintTimestamp | uint256 | The timestamp when the NFT was minted. |
Errors
SettlementNft_SingleActivePerAddress
error SettlementNft_SingleActivePerAddress();