Hedgeys NFT
Smart Contract Overview
The Hedgeys smart contract is a version of the ERC721 smart contract, often referred to as an NFT contract, that extends the enumerable extension from openzeppelin. Most of the core functions and documentation on ERC721 contracts can be better explained by the amazing openzepplin team here. We will not dive into the various standard ERC721 functions in this section, but rather focus on what makes the Hedgeys NFT smart contracts unique.
Token-Time-Lock Functions
Hedgeys smart contract allows users to mint an NFT that represents more than their metadata and image URL; it represents a token-time-lock. The token-time-lock is comprised of three elements, which we store in a global struct called a Future
. The NFT tokenId
is mapped uniquely to each Future
, as a variable futures
that is publicly accessible. So when a user is looking up their metadata by their tokenId
they can also pull the future details with a function simply futures[tokenId]
. A Future struct contains three key value pairs:
amount
: The amount of tokens that are lockedtoken
: The ERC20 contract address of the token that is lockedunlockDate
: The unix time stamp when these tokens will unlock and are redeemable
When you mint an NFT you also create a Future
. Itβs that simple!
createNFT
: This is the function that will mint an NFT and additional lock your desired tokens into the contract - creating the Future struct
redeemNFT
: This is the function that will burn your NFT in exchange for redeeming your locked tokens and in return deliver out of the contract tokens to the you (as the owner).
The Github Repository contract is here
Last updated