MortgageNFT
Inherits: IMortgageNFT, ERC721
Title: The MortgageNFT contract
Author: SocksNFlops
The MortgageNFT contract is a non-fungible token that represents ownership of a mortgage position in LoanManager
State Variables
generalManager
Returns the general manager address
address public immutable override generalManager
nftMetadataGenerator
Returns the NFT metadata generator address
address public immutable override nftMetadataGenerator
getMortgageId
mapping(uint256 => string) public override getMortgageId
getTokenId
mapping(string => uint256) public override getTokenId
lastTokenIdCreated
Returns the last tokenId created
uint256 public override lastTokenIdCreated
Functions
constructor
Constructor
constructor(string memory name, string memory symbol, address generalManager_, address nftMetadataGenerator_)
ERC721(name, symbol);
Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the NFT |
symbol | string | The symbol of the NFT |
generalManager_ | address | The address of the general manager |
nftMetadataGenerator_ | address | The address of the NFT metadata generator |
mortgageIdNotTaken
Modifier to check if the mortgage ID is already taken
modifier mortgageIdNotTaken(string memory mortgageId) ;
Parameters
| Name | Type | Description |
|---|---|---|
mortgageId | string | The mortgage ID to check |
onlyGeneralManager
Modifier to check if the caller is the general manager
modifier onlyGeneralManager() ;
mint
Mints a new mortgage NFT. Only the general manager can mint new NFTs.
function mint(address to, string memory mortgageId)
external
mortgageIdNotTaken(mortgageId)
onlyGeneralManager
returns (uint256 tokenId);
Parameters
| Name | Type | Description |
|---|---|---|
to | address | The address to mint the NFT to |
mortgageId | string | The ID of the mortgage |
Returns
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The ID of the minted NFT |
burn
Burns a mortgage NFT. Only the general manager can burn NFTs.
function burn(uint256 tokenId) external onlyGeneralManager;
Parameters
| Name | Type | Description |
|---|---|---|
tokenId | uint256 | The ID of the mortgage position to burn |
ownerOf
Gets the owner of a mortgage position by its mortgage ID
function ownerOf(string memory mortgageId) external view returns (address owner);
Parameters
| Name | Type | Description |
|---|---|---|
mortgageId | string | The ID of the mortgage |
Returns
| Name | Type | Description |
|---|---|---|
owner | address | The owner of the mortgage position |
tokenURI
function tokenURI(uint256 tokenId) public view override returns (string memory);