Skip to main content

MortgageNFT

Git Source

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

NameTypeDescription
namestringThe name of the NFT
symbolstringThe symbol of the NFT
generalManager_addressThe address of the general manager
nftMetadataGenerator_addressThe address of the NFT metadata generator

mortgageIdNotTaken

Modifier to check if the mortgage ID is already taken

modifier mortgageIdNotTaken(string memory mortgageId) ;

Parameters

NameTypeDescription
mortgageIdstringThe 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

NameTypeDescription
toaddressThe address to mint the NFT to
mortgageIdstringThe ID of the mortgage

Returns

NameTypeDescription
tokenIduint256The ID of the minted NFT

burn

Burns a mortgage NFT. Only the general manager can burn NFTs.

function burn(uint256 tokenId) external onlyGeneralManager;

Parameters

NameTypeDescription
tokenIduint256The 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

NameTypeDescription
mortgageIdstringThe ID of the mortgage

Returns

NameTypeDescription
owneraddressThe owner of the mortgage position

tokenURI

function tokenURI(uint256 tokenId) public view override returns (string memory);