This was one of the craziest hackathons i have done till the date.
So with very high excitement and enthusiasm we started our mainnet hackathon.
The hackathon started with me not able to setup the sample repo in my windows system till last 2nd day of the hackathon.
I tried updating wsl, deleting, reinstalling and what not.
Then i created a virtual image of a Debian Os and tried to setup the repo there but still we were facing issues there due to some permission issues.
Then my Savior(hashwarlock ~ josh) who is Director of Tech Evangelism at Phala Network updated the repo with the code supporting windows system and i was good to go.
Next Day i skipped college and coded the backend of the project with josh in our Developer Dao voice channel, i had faced many errors(smartcontract, encoding, decoding, tests, variable setting and wat not) but josh was there to help me with them and without him 100% i won’t be able to finish the project.
After setting up the sample code i went through it and understood various parts of the code, the pink package of Phala which can only be used in the code to make http get, put, post requests .
Then i learned how to make API using node and express and deployed my API for storing data about my characters .
This time i also introduced Notifications in the game, whosoever is the winner, a notification about his winning is sent into the public group with his powers and score.
Channel Address of Live Push Channel(https://staging.push.org/)(0x0dDda6871f1216D7EF56722167652e4F881d74Aa)
Following data is stored in the API:
Nature of the character : Fire, Water, Earth, nature, according to this the character gets Power Ups.
Special Attacks: Attack1, 2 and 3 using these attacks the player can have an extra edge against the opponent.
Further we are querying this data using Pink library as a batchttp request with another lens api to query the profile data and we are getting the data in return in form of a array .
Further we are using this array to send data to our Consumer contract deployed on mumbai and then we are listening for event "ResponseReceived” with a webSocket.
Once our React app receives data from the event listener, we are setting that data on our frontend and then starting the game.
Now if the player 1 has Fire Attribute and Player 2 has Water Attribute then Player 1 will get 1000points + because of the Power Attribute.
After the match finishes, the winner gets to mint a Nft of this on-Chain score and if he/she/they already have one then their score on the Nft gets updated.
The hackathon started with me getting sick
then my teammate got sick
then i found a new teammate to code with.
and also found a bug in Lens Oracle due to which the oracle gets shutdown automatically and was awarded a bounty for this finding from Phala Network team.
I started by exploring Phala Network ,it’s oracles and how things are done.
At start it looked hard but is somewhat easy.
It took me 15 mins to setup a consumer contract with lens oracle at start and now i do it in under 2 mins.
It's a Onchain Game in which your lens State acts as your score.
A game of Stat vs Stat for 2 Lens profiles to compete with the stat total they have on their Lens profile
Your total score depends on :
We are fetching above data from a Lens oracle deployed on Phala Network.
A consumer contract is deployed on Polygon-Mumbai to fetch data from Lens Oracle(https://mumbai.polygonscan.com/address/0x8a0ed779d131dAe2Ca8b0a7606e02944Ee611F79) .
If your score is greater then player 2 , you win.
The opponent is selected randomly for battle .
I would like to give a shoutout to hashwarlock( Director of Tech Evangelism at Phala Network) to constantly be available for every help possible be it oracle not responding or some technical error.