Odak modu

Build on Chiliz

Homework I - Submit your github repository link

Now it is your turn to modify the already existing content. Let’s modify the entry requirement for Accessing MeetPage. Currently, the only requirement is holding native token (CHZ), now let’s add the requirement of holding any fantoken of your choosing.

Step 1: Get Token Balances

From the useBalances hook, we are importing message and nativeBalance. Now let’s also add tokenBalances to the imports we are making.

change this line:

const { message, nativeBalance } = useBalances();

to:

const { message,tokenBalance, nativeBalance } = useBalances();

Step 2: Get Specific Token Balance

tokenBalance is an array containing all the tokens the user owns. From that array, check if the fantoken of your choosing exists and it has a balance greater than 1.

Note: You can check if the fan token you choose exists in this array using symbol or token_address (For instance, in token_balances array, check if the user has token with token_address: 0xF9C0F80a6c67b1B39bdDF00ecD57f2533ef5b688. If token_balances array does not contain an item with this address, means that the user do not posses any and, therefore can not join the meeting)

Step 3: Add condition to isEligible

If the token exists in the tokenBalance array, we can check for the balance from the same array but it contains decimals. Therefore before checking if the balance is greater than 1, you need to get rid of decimals. In other words, instead of checking if balance > 1, you need to do formatBalance(balance) > 1 (just like what we have done with nativeBalance).

Finished version of Virtual meet-up platform:

Github Link

left-disk

Yazılım Kariyerinde İlerlemeni Hızlandıracak Programlar

Patika+ programlarımız ile 4-8 aylık yoğun yazılım kamplarına katıl, temel bilgilerden başlayarak kapsamlı bilgiler edin, yazılım kariyerine başla!

right-cube

Ödev

Yorumlar

Yorum yapabilmek için derse kayıt olmalısın!