This smart contract demo project demonstrates membership functionality. When you buy the NFT, part of the payment is for club access and the reminder is intrinsic value that dwindles in time. As long as the account has not expired, the NFT will report the current account holder as being active. Once it expires, well, it doesn’t.
How it works
When the hodler buys the NFT, there are two things that are being purchased at the same time: The NFT mint and membership access. A predetermined portion of the mint cost goes directly to the smart contract to be held on account of the creator as the NFT minting fee. The remaining value becomes intrinsic value held on behave of the hodler which will be allocated to the creator, in time, as the membership fee is charged.
At any time, the hodler can withdraw his remaining funds from the contract.
At any time, the hodler can apply funds to his account.
As long as there is intrinsic value on the NFT, it will not expire. Once funds run out, the NFT signals that it’s expired. Membership access is denied when the NFT can be renewed.
The hodler can reinstate their membership at any time, but if they let the membership expire, there will be an additional activation fee to restart the process.
Inside the code
Because this is a demo project, the NFT code demonstrates how to use the Penny Oracle along with how to manage intrinsic value in an NFT. The Penny Oracle is used to suggest and verify that the correct amount of Tfuel is being used. The intrinsic value functionality is observable via contract function calls and in the visual state of the NFT. As the membership state changes, so does the metadata that the contract exports which define the characteristics of the individual token.
All source is published on the project server and uses the metadata hash functionality for file source validation.
Minting
The cost of the mint will be $0.25. A mint will not be allowed unless the contract is provided $1.25 in tfuel, of which, $1 worth of this tfuel is the intrinsic value which funds the membership fee.
Reactivation fee is $0.10 in tfuel, thus the hodler must send more than $0.10 in order to exceed the activation fee and fund the membership. The reactivation should add enough penny’s worth of time in order to get the functionality that they want done.
Membership Fee
Once minted, the membership fee is calculated at 1 penny per hour. As long as the membership fee can be paid, the NFT will remain active. If not, it will be considered expired. Yet, you still own the NFT and can renew the membership at any time.
The NFT will expose a method for determining time left to the membership.
Adding or removing funds
The hodler can withdraw their intrinsic value at any time. Once they do, the NFT becomes expired.
Funds can be added to the NFT at any time. If the hodler lets the NFT expire, there is a reactivation fee that will be deducted from the payment in order to get the NFT out of the expired state. (See minting above.)
Adding funds is based on NFT Id. This allows for anyone to pay for an accounts access and allows the funds to transfer if ownership changes.
Demo Rewards Scenario
Because this is a demo, the first 42 accounts that:
- Mint one of these NFTs, then
- Withdraw their intrinsic value, then
- Renew their account, then
- When their account has exactly 15 hours left, then
- Claim their prize before the hour is out.
The contract will open a window of time when the participant can claim their participation reward. There will be a claim function that will need to be called during the 15th hour before expiration. Once claimed, the token metadata will change to reflect the reward.
Participation Reward
The participation reward is Kalamazoo! A one of a kind, magically original, short story authored by me (Amor).
When the claim is successful, the metadata for the individual’s token will change to reflect the winning status and contain a link to a PDF version of the story. The PDF file has already been hashed and that hash is included in the project file proving it’s tamper-resistant properties.
Credits
Would like to thank everyone that has encouraged me to continue to explore what smart contracts can do on the Theta Blockchain.