# My experience of Phala Network Hackathon

By [Shubh](https://paragraph.com/@shubh-5) · 2023-08-28

---

This was one of the craziest hackathons i have done till the date.

Phala Mainnet Hackathon- LensPhitev2 with Notifications, Dynamic Nfts and on-Chain scores.
------------------------------------------------------------------------------------------

![Home Page of V2](https://storage.googleapis.com/papyrus_images/7ed33d588f63084b92e1dc376c6640358baea758f71f0283d1c77d8709a66cbb.png)

Home Page of V2

*   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 j**osh 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](https://staging.push.org/\)\(0x0dDda6871f1216D7EF56722167652e4F881d74Aa))
    

![Push Notification about winning](https://storage.googleapis.com/papyrus_images/7b2bffbc6b27184a424696d49997d9a58d2922c86a58e7a130c2ef784642506a.png)

Push Notification about winning

*   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.
        

![Api for Querying character data.](https://storage.googleapis.com/papyrus_images/3bfa7d8f284ea8afd8638f2b9297d19960f60e6a7f22704181c66dfeaf10f154.png)

Api for Querying character data.

*   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.
        
        *   OpenSea-Collection of Nfts : ([https://testnets.opensea.io/collection/chain-battles-275](https://testnets.opensea.io/collection/chain-battles-275))
            

![Nft with Dynamic Levels](https://storage.googleapis.com/papyrus_images/844eceaea4682b7213cb31cc1ddfbc31e201e1d5e6c92307a9d48d05d4d166f0.png)

Nft with Dynamic Levels

*   The below is how the Battle Ground looks like in the game:
    

![Battleground of LensPhite](https://storage.googleapis.com/papyrus_images/b8c05b1daefa8b9ad5277816dab6e97074cca9d84dc8b6fc582bfa157380ca38.png)

Battleground of LensPhite

*   I hope you liked the project.
    

Phala Testnet Hackathon Experience
----------------------------------

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**.
    
    Our Project : Lens Phite with Onchain score
    -------------------------------------------
    

![Battle Ground](https://storage.googleapis.com/papyrus_images/e877dd79f3886fe1f5763df725003187ec8c6a278a45fb7d6100e30bbffeed21.png)

Battle Ground

![Landing page](https://storage.googleapis.com/papyrus_images/f24db242ff36cc2203da9b6be2393ccaa656e21e6b46df99fa16ae6e0542e714.png)

Landing page

\*

*   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 :
        
        *   **Your Posts**
            
        *   **Your Following**
            
        *   **Your Followers**
            
    *   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](https://mumbai.polygonscan.com/address/0x8a0ed779d131dAe2Ca8b0a7606e02944Ee611F79)) .
        
    *   If your score is **greater then player 2** , you win.
        

The winner's score is updated in a Unique Nft with onChain Level, and everytime a user wins,the Level is increased .
--------------------------------------------------------------------------------------------------------------------

![](https://storage.googleapis.com/papyrus_images/fb6505079a3ffeffc54f44c817a6ab4d5e36d899b5fc59533d0f6c8426c349c9.png)

*   Collection : [https://mumbai.polygonscan.com/token/0x16cb27eb3b6e2c3da78e08f54f41b329a6c0b1f3](https://mumbai.polygonscan.com/token/0x16cb27eb3b6e2c3da78e08f54f41b329a6c0b1f3)
    
*   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.

---

*Originally published on [Shubh](https://paragraph.com/@shubh-5/my-experience-of-phala-network-hackathon)*
