How to earn by predicting the winning teams of World Cup Football
Learn how to earn by playing the World Cup NFT Fantasy Game
π Welcome
Welcome, everyone! In this guide, we will be talking about what WC NFT Fantasy is, how to get started and some technical details on the project.
π€ What is this project?
WC NFT Fantasy is a NFT prediction-based game that you can play to win. The game lets you pick 4 teams that you predict will win the FIFA World Cup 2022 in that order, and win the prize pool if you guessed it right!
If multiple people guessed the right answer, then the winner will be selected by True on-chain Randomness (Using Chainlink VRF).
You can visit this page if you want a quick overview to get started.
ποΈ What do I need before getting started?
You need a minimum of 4 Matic + gas fees to mint the first 4 teams and join the main prediction game.
1 Matic costs $0.87 at the time of writing (0.87 x 4 β $3.5).
πΆββοΈ How do I enter the game?
Visit the website here.β¨
Click on Connect Wallet at the top right of the website
- Click on your wallet to connect using your favourite wallet.
If you donβt have a wallet and want to get started, click here to create a wallet. We recommend MetaMask.
If you donβt understand what web3 is, you can learn more here.
- Once connected, you can click on the Mint button on the Header, or scroll down until you see the section to Mint.
- Using the two buttons below to navigate, select the teams that you want in the exact order that you predict they will win. For example, if I predict that the following teams will win :
1 - Brazil, 2 - Argentina, 3 - France, 4 - England
It would look like this :
You can click on the Delete Selection button if you want to change the order
- Once you are sure of your selection, scroll down and click on the Mint button. After the section, this should pop up :
Insert the amount of Matic that you wish to bet on. Note that the minimum amount is 4 Matic (1 Matic per NFT x 4 NFTs).
After inserting the amount to mint, click on the button Confirm underneath and a confirmation from MetaMask (or your wallet) should pop up.
Confirm the popup to proceed with the transaction. In a little while, everything should be in order and you should have the NFTs.
Click on the Play Game button at the top of the website or go here to view your NFTs.
On this page, you can view your NFTs, evolve your teams if eligible, swap teams if eligible, and deposit your prediction points after the game ends.
π€ Swapping Teams
You swap teams when you feel another team has a chance than an existing selected team. Swapping is very limited, therefore, always be sure of the order that you choose to mint.
You can swap only between two teams at a given time. Assuming you minted the extra two teams that you can swap against, you can only perform the swap feature against the extra 2 teams in Round 32 and Round 16 of the game.
You can however swap from the main chosen 4 teams after each round announcement at Round 32, Round 16, Round 8, and Round 4 respectively.
In order to perform a swap, go into the Main Page.
π€·ββοΈ What do I do now?
Congrats! You have successfully entered the game. Now you have to watch the Football games and see how well you did your prediction.
π₯ What is Upgrading/Evolving?
There are four rounds that the Football game goes through before announcing its winners. After each round, if your team is in the tournament, you can upgrade or evolve your NFT.
Since you can only upgrade if the chosen team is selected for the next round, upgrading will change your NFT to make it way cooler and worth more.
Evolve Example :
This will cost some gas for the transaction since it will Mint you a new token.
β½οΈ Games
This will give you a quick overview of the types of games that exist in WC NFT Fantasy. The opening of the Quiz and Number game will be announced by us on Twitter, so check out the Teams section in this guide to follow us for that update!
π Prediction
This is the main game that you predict the winning teams in their order and win the main prize if guessed correctly.
π§ Quiz
This is a mini-game where you can win NFTs by answering the questions right (This may or may not be cool level 3 NFTs).
You can do the quiz here when it's opened.
π Number Guessing
The Number Guess game is all about guessing a random number right to win a cool NFT if you do. This game will be available after the Quiz game mentioned above.
π Technical Details
In this section, I will talk about the technical aspect of this project. This includes explanations of various technologies and techniques used, with links to frameworks/stacks used.
βοΈ Frontend
We have used Next JS on the Front end, along with the following plugins :
- Rainbowkit for Wallet handling and connection.
- Axios to fetch queries from the Subgraph (explained later).
- Ethers for EVM Interactions and conversions.
- GSAP for handling animations.
- Next-SEO for SEO Management within the website.
- TailwindCSS for CSS consistency within the project.
All the frontend code van be viewed in this repository. Our frontend is more focused on UX (User Experience), therefore uses great UI (User Interface) and built in a way focused to make the users interact with the smart contract backend easier and smoother.
π Backend
The backend in our project is quite complicated and has a lot of contracts and techniques used to make it possible. I will try my best to explain this as smoother as possible.
Summary
We have created 9 different contracts (A total of more than 15) for this game to work.
The main Prediction uses ERC1155 to build an upgradable contract.
Note that you cannot transfer NFTs until the tournament is completely over.
Here is a summary of each of those 9 contracts and how they work.
- Contract WCNFTFantasy/Prediction.sol - Allows predictors to mint their teams, deposit their winners, and this chooses the winners using VRF. Keepers gets called every 24 hours to check the conditions of the game.
- Contract ChangeOrders - Allows predictors to change the order of their prediction every time the World Cup enters a new round.
- Contract Evolve - Predictors can evolve their teams if that team has made it to the next World Cup round.
- Contract MintTeams One/Two - This is where the NFT exists gets called by Prediction.sol for users to be able to mint their teams.
- Contract FetchTeams One/Two/Three/Four - Fetches the teams that are still in the World Cup.
- Contract RetrieveRandomNumber - Fetches a random number from VRF.
- Contract WorldCupData Round 16/Round 8/Round 4 - Calls the API To retrieve the teams that are still in the World Cup.
- Contract QuizGame - Predictors can enter two Quiz games and potentially win a NFT.
- Contract NumberGuessingGame - Predictors can guess the random number from the VRF and potentially win a NFT.
Note : You can click on any of the contract names to take you to view their code.
Tech Used
Hardhat - To compile, test and deploy into the network.
Chainlink Price Feed - Determine how much users pay for teams.
- Chainlink VRF - Choose winners based on who predicted and the amount of points they scored.
- Chainlink Keepers - Autocall functions when different rounds start in the World Cup.
Chainlink Adapters - Call the API to receive the players that are still in the World Cup.
IPFS - Stored and deployed the NFT Images and the NFT Metadata in a decentralized way so that they cannot get altered by anyone including us and, the data will always be publicly accessible.
Quicknode - We used Quicknode to deploy all our smart contracts on the network.
Polygon - Enables us to deploy contracts in L2 blockchain which helps handle traffic for the rush in the event of buying tickets.
All of the backend code can be viewed from our repository.
β Subgraphs
We have used The Graph to query the data emitted from the events in the contract code and display them on the frontend.
You can view all of the files of the subgraph from our repository.
π₯ Team
This project was made by 4 people for the Chainlink Hackathon.
You can check other projects we have done here.
π Resources
β€οΈ Thank you
Thank you for reading this article. Suggestions and Feedback and very much welcome! Don't forget to like and share around if this helps.