https://www.youtube.com/watch?v=Fw6y3oatblE
Lens Consumer Contract
https://mumbai.polygonscan.com/address/0x9Bd7AFde187a8A21EABE0D71658892EAB6f9aeee
How to deploy contract
yarn deploy --network polygonMumbai
How to deploy frontend
cd packages/nextjs
vercel .
Action offchain rollup address
0x89e6979880f43cc42a1b2ee915895c61e123fc87d687ff88b0f18d7832f1b508
Attestor Address
0x2e725ef367550116f5d337faec42bbc14b867a9b
Demo
https://nextjs-koisose.vercel.app/
So this game is very simple, firstly, you need to choose one lens profile, lets say i pick lensprotocol
lens profile here i just need to click USE THIS AS MY FIGHTER
:
Don't forget to wait until it says Successfully set <username> as your fighter
, as you can see my lens fighter has 3341
Follower right so this game is a game of luck, its kinda like you throw a dice
with your friend but the dice is from 0 to lens profile follower count, so if the follower of my fighter is 3341
then i can get random number between 0 to 3341
, this can be done by using js
transformation method in Phat bricks ui:
So everytime i click fight here:
The smart contract will send request to offchain rollup, then will send back to us the result between fight this is the snippet of the smart contract:
as you can see there is an event called Winner
it will check whos the winner based on who has the bigger number calculated via the smart contract you can see the logic here:
there is also event Attack
to catch what number is picked by opponent and us this is what happen when we click fight button:
You can also see record in the My Fighter
tab