Balance returned is always 0 for a local dev server


I am using Moralis React and trying to get some basic functionality working. Authentication seems to be working well, but now i’d like to check the ETH balance of the connected wallet.

I followed this tutorial to connect the Moralis instance to my local Ganache chain.

And i am using the following code which returns 0 ETH in my metamask account.

The user object’s account details appear to have the correct address.

The below code is being used to enableWeb3 and get balances. However, the balance returned is 0 and i have 100ETH (the ganache default) in the account i am using. I have also tried to chaing the chain to the Ganache chainId.

function App() {
  const { isWeb3Enabled, enableWeb3, isAuthenticated, isWeb3EnableLoading, user } =

  const nativeBalance = useNativeBalance({ chain: "eth" });

  useEffect(() => {
    if (!isWeb3Enabled && isAuthenticated) {
      enableWeb3({ provider: "metamask" });
      console.log("web3 activated");
  }, [isWeb3Enabled, isAuthenticated, enableWeb3]);

  return <div></div>;

Any clues as to how to solve this issue?
Does anyone have a working complete boilderplate example of how to use Moralis React?


After searching on this forum, i found another code snippet. This just returns an empty array.

  useEffect(async () => {
    if (!isWeb3Enabled && isAuthenticated) {
      enableWeb3({ provider: "metamask" });
      console.log("web3 activated");
      console.log("before getTokenBalances");
      let payload_ = {
        chain: "eth",
        address: "MY WALLET ADDRESS",
      let balances_ = await Web3Api.account.getTokenBalances(payload_);
  }, [isWeb3Enabled, isAuthenticated, enableWeb3]);


I also found this…

“web3api calls don’t work with local dev chain, probably that is the problem. It should work on a testnet network.” @cryptokid

So… what is the purpose of the local dev chain setup? If it is not possible to interact with the locally deployed Ganache blockchain. This is very confusing.

yes, web3api calls don’t work with local devchain, you may get some data synced in your Moralis Server db that you could query