From that error it looks like you also need to provide other parameters besides the chain id
Iāve checked but I couldnāt find any other parameters that might be missing. Cos what I did was follow the rest of the blockchain that is added on the boilerplate code.
Is it possible that your team could update the react-moralis library so that it supports the AVAX testnet? Iām doing this cos Iām joining your avalanche hackathon. I think this will absolutely benefit the other participants.
What do you think?
It should be now, I think you will need update the react-moralis
version to the latest one because fuji
has not included in our SDK when the tutorial comes out let me know if you still find any issue
Oh great @YosephKS. Terima kasih!
But Iām sooo new to all this cos Iām an old-school coder. Jut got back to coding after 15 year of absence. How do you update the SDK? Do I run npm update
or yarn upgrade
or something else?
I just did yarn upgrade --latest
and I got this. I think below is the latest.
"name": "react-moralis",
"version": "0.3.11",
But Iām still getting the error below from dashboard log, although my browser console.log has stopped seeing red.
2022-01-13T09:26:30.751Z - Failed running cloud function getNFTs for user undefined with:
Input: {"chain":"0xa869"}
Error: {"message":"required param address not provided","code":141}
Great seems like itās the latest version, btw can you show me how do you call the getNFTs
web3 API? do you by any chance just include the chain
as the only params?
The file below is taken from https://github.com/ethereum-boilerplate/ethereum-nft-marketplace-boilerplate/blob/main/src/hooks/useNFTBalance.js. I did not change anything.
See the } = useMoralisWeb3ApiCall(account.getNFTs, { chain: chainId, ...options });
import { useMoralisDapp } from "providers/MoralisDappProvider/MoralisDappProvider";
import { useEffect, useState } from "react";
import { useMoralisWeb3Api, useMoralisWeb3ApiCall } from "react-moralis";
import { useIPFS } from "./useIPFS";
export const useNFTBalance = (options) => {
const { account } = useMoralisWeb3Api();
const { chainId } = useMoralisDapp();
const { resolveLink } = useIPFS();
const [NFTBalance, setNFTBalance] = useState([]);
const {
fetch: getNFTBalance,
data,
error,
isLoading,
} = useMoralisWeb3ApiCall(account.getNFTs, { chain: chainId, ...options });
const [fetchSuccess, setFetchSuccess] = useState(true);
useEffect(async () => {
if (data?.result) {
const NFTs = data.result;
setFetchSuccess(true);
for (let NFT of NFTs) {
if (NFT?.metadata) {
NFT.metadata = JSON.parse(NFT.metadata);
NFT.image = resolveLink(NFT.metadata?.image);
} else if (NFT?.token_uri) {
try {
await fetch(NFT.token_uri)
.then((response) => response.json())
.then((data) => {
NFT.image = resolveLink(data.image);
});
} catch (error) {
setFetchSuccess(false);
/* !!Temporary work around to avoid CORS issues when retrieving NFT images!!
Create a proxy server as per https://dev.to/terieyenike/how-to-create-a-proxy-server-on-heroku-5b5c
Replace <your url here> with your proxy server_url below
Remove comments :)
try {
await fetch(`<your url here>/${NFT.token_uri}`)
.then(response => response.json())
.then(data => {
NFT.image = resolveLink(data.image);
});
} catch (error) {
setFetchSuccess(false);
}
*/
}
}
}
setNFTBalance(NFTs);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data]);
return { getNFTBalance, NFTBalance, fetchSuccess, error, isLoading };
};
Actually, now I canāt see any of my NFTs on ETH, Mumbai or Avalanche Fuji. Previously before upgrade I could. Funny thing is now browser console doesnāt show anymore error.
I have a few NFTs as shown here - https://testnet.snowtrace.io/tokentxns-nft?a=0xCA6c272710698bbF3358c8131035CbD2AFDFea67
Hmmmm thatās quite strange ohh btw just wondering when you upgraded the react-moralis
did you try to upgrade moralis
SDK too?
Oh, moralis SDK is different? OMG. Hang on, let me check out how to do it.
Ok, Iām doing it now.
Ok done. But Iām still getting the same status quo as after I upgraded react-moralis. Error with function getNFTs and seeing no Nfts on the site
What you call getNFTs, you are authenticated or you set the address parameter?
To be honest, Iām not sure. Cos your colleague wrote it -> https://www.youtube.com/watch?v=WZWCzsB1xUE
But I think itās to call your Moralis server to get the list of NFTs from my wallet. So, I have Moralis server connected to Avalanche testnet and my React connects to it to get my list of NFTs. Iām using the same address to login to my React site - 0xCA6c272710698bbF3358c8131035CbD2AFDFea67
And hereās the screenshot.
Strange what if you try to specify the address
param with your address?
I really have no idea how to specify it to be honest. I only started learning react today. Iām a Java, PHP, vanilla JS kinda guyā¦lol. React is quite out of this world to me.
WAit. Hereās the funny thing. I stopped running my React site for 30 mins already and the error is still appearing on my dashboard log. Perhaps thereās someone to do with your server?
if you restart the server the logs will also reset, in case that it would help you
Do u mean restart my moralis server or my react site?
I mean you Moralis Server, it will end up clearing the logs that you see in that dashboard