Getting NaN with "I cloned ZERION in 20minutes"

Hi,

@mayjer (author of this great video?)

I have installed your code from the https://github.com/MoralisWeb3/demo-apps/archive/refs/heads/main.zip since i could not clone it from the repo itself and as described in the md file (=> empty react app).

After installing (see my previous post Zerion cloned: cloud functions error [Solved] ) the app runsā€¦

but I get a NaN ā€¦

The Metamask is set to the ropsten network and the account has 2.996 ETH availableā€¦
afbeelding

What can be the reason?

Yes I made the Zerion Clone video. Glad you enjoyed it!

This may be a bug in the useCoinData() hook where it calculates the price in the case where there is only an eth balance and no token transactions. Take a look at the calculation of totalBalance in the hook. If you find the bug youā€™re welcome to make a pull request. Unfortunately, I wonā€™t be getting back to this project for a while as there are some high priority back end features for Moralis weā€™re working on right now.

1 Like

If someone has solutions to this please post it here. :snail:

The problem is with ā€œoutput.amountā€ value. I have tried to fix it whole day now.

How can I get metamaskā€™s eth amount value to it?

          let totalBalance = 0;
          const newList = tokens.map((token) => {
            const output = { ...tokens };
            const tokenData = data[token.symbol.toUpperCase()];
            output.price = tokenData?.current_price || 0;
            output.image = tokenData?.image;
            output.amount = tokenValue(+output.balance, +output.decimals); //amount value NaN
            output.value = output.price * output.amount;
            totalBalance += output.value;
            output.valueTxt = tokenValueTxt(
              +output.balance,
              +output.decimals,
              output.symbol
            );```