Created
February 16, 2023 20:07
-
-
Save floatbeta/6c1a36edfd1042935a2f83aad3f5453d to your computer and use it in GitHub Desktop.
Here's an example smart contract in Lua that burns an NFT after 1 month from the minted date.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function burnNFT(nftID) | |
local mintTime = getNFTMintTime(nftID) | |
local currentTime = os.time() | |
local secondsInDay = 60 * 60 * 24 | |
local secondsToBurn = secondsInDay * 31 | |
if (currentTime - mintTime >= secondsToBurn) then | |
burnNFTByID(nftID) | |
return "NFT " .. nftID .. " burned" | |
else | |
return "NFT " .. nftID .. " cannot be burned yet" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This smart contract first gets the mint time of the NFT by calling getNFTMintTime(nftID), which should return a Unix timestamp representing the time the NFT was minted.
It then gets the current time using os.time(), and calculates the number of seconds that have passed since the NFT was minted.
If 31 or more days have passed, the NFT is burned by calling burnNFTByID(nftID) and a message is returned indicating that the NFT was burned.
If less than 31 days have passed, a message is returned indicating that the NFT cannot be burned yet.