-
High - 100xp
-
Medium - 20xp
-
Low - 2xp
-
Starts: November 30, 2023 Noon UTC
-
Ends: December 07, 2023 Noon UTC
- nSLOC: 116
- Complexity Score: 83
Santa has adopted blockchain technology to keep track of the naughty and nice! Hooray! So Santa hired some south pole contract elves to help build him a blockchain-based list. He'd never worked with blockchain elves before but was excited to see what they could do! They got nearly 100% test coverage, so that's got to be good, right?
The codebase is broken up into 3 contracts:
SantasList.solSantaToken.solTokenUri.sol
Santa's List is the main contract that stores the list of naughty and nice people. It doubles as an NFT contract that people can collect if they are NICE or EXTRA_NICE. In order for someone to be considered NICE or EXTRA_NICE they must be first "checked twice" by Santa.
Once they are checked twice, NICE users can collect their NFT, and EXTRA_NICE users can collect their NFT and they are given SantaTokens. The SantaToken is an ERC20 that can be used to buy the NFT for their NAUGHTY or UNKNOWN friends.
In this contract Only Santa to take the following actions:
checkList: A function that changes anaddressto a newStatusofNICE,EXTRA_NICE,NAUGHTY, orUNKNOWNon the originals_theListCheckedOncelist.checkTwice: A function that changes anaddressto a newStatusofNICE,EXTRA_NICE,NAUGHTY, orUNKNOWNon the news_theListCheckedTwicelist only if someone has already been marked on thes_theListCheckedOnce.
You can see what a Christmas NFT present looks like here!
The following functions are meant to be called by people, but only those marked NICE or EXTRA_NICE can benefit from them.
collectNFT: A function that allows aNICEorEXTRA_NICEuser to collect their NFT.EXTRA_NICEusers also receiveSantaTokenwhich is used to purchase an additional NFTs. An address is only allowed to collect 1 NFT per address, there is a check in the codebase to prevent someone from minting duplicate NFTs.buyPresent: A function that trades2e18ofSantaTokenfor an NFT. This function can be called by anyone.
This codebase is based off solmate a Modern, opinionated, and gas optimized building blocks for smart contract development. The ERC20 is a typical ERC20 with the following changes:
- Only
SantasListcan mint tokens - Only
SantasListcan burn tokens (well, technically anyone can, but onlySantasListcan call the burn function)
A minimal contract that exclusively has the tokenURI. It's a separate contract inherited by SantasList for readability purposes.
Santa- Deployer of the protocol, should only be able to do 2 things:checkList- Check the list oncecheckTwice- Check the list twice- Additionally, it's OK if Santa mints themselves tokens.
User- Can buyPresents and mint NFTs depending on their status of NICE, NAUGHTY, EXTRA-NICE or UNKNOWN
- git
- You'll know you did it right if you can run
git --versionand you see a response likegit version x.x.x
- You'll know you did it right if you can run
- foundry
- You'll know you did it right if you can run
forge --versionand you see a response likeforge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)
- You'll know you did it right if you can run
git clone https://github.com/Cyfrin/2023-11-Santas-List
cd 2023-11-Santas-List
make
Or optionally, you can run:
forge install
forge build
forge test
forge coverage
and for coverage based testing:
forge coverage --report debug
- Commit Hash: 91c8f8c94a9ff2db91f0ab2b2742cf1739dd6374
- In Scope:
./src/
#-- SantaToken.sol
#-- SantasList.sol
#-- TokenUri.sol
- Solc Version: 0.8.22
- Chain(s) to deploy contract to:
- Arbitrum
- Tokens
SantaToken
- We are aware that we are missing a number of zero address checks, please ignore.
- The Christmas date is approximate, if it's more then 24 hours before or after Christmas, please report that. Otherwise, it's OK.