This simple application uses a smart contract to distribute membership NFT when users pays for the membership fee by depositing certain amount of Algos. Users can always cancel their membership and get back their Algos they paid for the membership. Once membership is cancelled, the membership NFT is clawbacked and transferred back to the membership smart contract.
To showcase Algorand Standard Asset (ASA) capabilities, the membership NFT is defaulted to be frozen and able to be clawbacked.
All developers are welcome to participate in the Algorand Hacker Mansion Coding Challenge. Valid submissions before March 8th, 2024 will get awarded a unique NFT.
In this assignment, you will be building a multi-tier membership feature that gives out different membership NFTs based on how much Algos the user pays.
Implement a smart contract that has three tiers of membership (Gold, Silver, Bronze), each priced at 50 Algos, 25 Algos, and 10 Algos respectively. The smart contract should be able to determine which membership NFT to issue based on the amount of Algos received through the getMembership()
smart contract method. Each account can only hold one membership regardless of the tier.
- Fork this repository
- Clone the forked repo to your local machine and implement the multi-tier feature.
- After implementing the smart multi-tier feature, edit the test file in ./__test__ to test your new feature. If all of your tests pass, make a PR to this branch from your forked repo. The Algorand DevRel team will evaluate your submission and once approved, we will share the magic link to claim your certificate of completion!
This project assumes you have a local network running on your machine. The easiet way to setup a local network is with algokit. If you don't have Algokit or its dependencies installed locally you can open this repository in a GitHub codespace via https://codespaces.new and choosing this repo.
- Go to the directory you want to work in with your terminal and clone the repository
cd [DIRECTORY_OF_YOUR_CHOICE]
git clone [FORKED_REPO_URL]
- Open the cloned repository with the code editor of your choosing. The below code example works only if you are using VSCode as your default editor and have the
code .
shorthand set up.
cd [CLONED_REPO]
code .
- Install dependencies using AlgoKit. Run the below command
algokit bootstrap all
npm run build
will compile the contract to TEAL and generate an ABI and appspec JSON in ./contracts/artifacts and a algokit TypeScript client in ./contracts/clients.
npm run compile-contract
or npm run generate-client
can be used to compile the contract or generate the contract seperately.
npm run test
will execute the tests defined in ./__test__
npm run lint
will lint the contracts and tests with ESLint.
For TEALScript documentation, go to https://tealscript.algo.xyz