Skip to content

Instantly share code, notes, and snippets.

@floatbeta
Created February 16, 2023 20:07
Show Gist options
  • Save floatbeta/6c1a36edfd1042935a2f83aad3f5453d to your computer and use it in GitHub Desktop.
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.
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
@floatbeta
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment