Web3 Kitties project - not working

I am once again having problems with Web3 - - I keep getting new errors and the buttons don’t work

cryptoKitties_web3_errors

1 Like

Hey @bjamRez, hope your ok.

I have moved your topic to the proper category of the course in subject, would be appreciate it if you can post it on the proper category next time :nerd_face:

Please share your github repo of the project so i can take a look on it, it might be that you are console.log the functions instead of the result, have to check the code.

Carlos Z

https://github.com/brlojam4932/myCryptoKitties_master.git

Sorry about that Carlos
I see Mauro posted the link but here it is
https://github.com/brlojam4932/myCryptoKitties_master.git

///// SORRY SORRY SORRY/////

I think current code is working - the reason I can’t see the html / jquery printing back out the result, is because the font is black on a dark background so I could not see it. Somehow - the color changed and I thought it was not working so never mind this problem for now. So sorry

1 Like

/////////// DISREGARDE, I FOUND THE ERRORS TO BOTH PROBLEMS /////////////////////////

The empty array problem: The getAllTokensForUser function was missing a return statement

return result;

The problem with block.timestamp displaying time, back in 1970 was due to missing parenthesis in the Main.js time functions

// INCORRECT:
let deathTime = new Date(parseInt(data.lastMeal) + parseInt(data.endurance) * 1000);

// CORRECTED
let deathTime = new Date((parseInt(data.lastMeal) + parseInt(data.endurance)) * 1000);

///////////////// block.timestamp is still unclear why it defaults to 1970 /////////////////

Hello Carlos, sorry but I still think there is a gap in the Crypto Kitties course. It jumps from the breeding function to, all of a sudden, a catalogue full of NFTs already “finalized” and organized on a new page. This was never mentioned in any of the videos prior.

Anyways. I found Filip’s Game NFT in Moralis… it explains step by step how to finalize each cat and move it to a Catalogue of NFTs.

I had some problems related to block.timestamp which I solved by adding more time so that it would not show the time back in 1970.

here is how

 let deathTime = new Date(parseInt(data.lastMeal) + parseInt(data.endurance) * 16255100);

So this works but not as intended - like Philips.

but more importantly, I also got an empty array and I get an error in the Ganache window when I try to look at the transaction. after generating an NFT.

https://github.com/brlojam4932/NFT_GAMES_BL.git

link to Filip’s video
https://youtu.be/oSpkqzPZ2Wo?t=643

pet_nft_empty_array

While using the terminal, ERC721 get functions seem to be returning two NFTs but when I use the get array function from the course, it returns the empty array.

truffle(development)> tokenInstance.ownerOf(0)
'0xe898a745ECa4791f5b6e0ffd397ECF9E3C4d737c'
truffle(development)> tokenInstance.ownerOf(1)
'0xe898a745ECa4791f5b6e0ffd397ECF9E3C4d737c'
truffle(development)> tokenInstance.getAllTokensForUser('0xe898a745ECa4791f5b6e0ffd397ECF9E3C4d737c')
[]
truffle(development)> tokenInstance.balanceOf(accounts[0])
BN { negative: 0, words: [ 2, <1 empty item> ], length: 1, red: null }
truffle(development)> tokenInstance.ownerOf(0)
'0xe898a745ECa4791f5b6e0ffd397ECF9E3C4d737c'
truffle(development)>