[SOLVED] Cannot get wallet token balances with sdk, error [C0005]

Hi,

await Moralis.EvmApi.token.getWalletTokenBalances({
			address,
			chain,
		});

I get this error message:

{"name":"Moralis SDK Core Error","isMoralisError":true,"code":"C0005"}}

I’ve googled the error to no avail.

Here’s the rest of the code:

import { Request, Response } from 'express';
import Moralis from 'moralis';

import { EvmChain } from 'moralis/common-evm-utils'

export async function getWalletTokenBalances(request: Request, response: Response) {
	Moralis.start({
		apiKey: process.env.MORALIS_API_KEY,
	})

	const { address } = request.params || {};
	const chain = request.query.chain as string || EvmChain.ETHEREUM;

	console.log(address, chain);
	try {
		const moralisResponse = await Moralis.EvmApi.token.getWalletTokenBalances({
			address,
			chain,
		});

		if (moralisResponse) {
			response.json(moralisResponse.result);
			return;
		}
	} catch (e) {
		response.status(500).json({
			message: 'Fetching the token balances has encountered an error',
			error: e
		});
	}
}
1 Like

Can you log the parameters to be sure that they have the expected values?

I do, the first one is an acceptable address according to ethers, and the second one comes out to “eth”.

Bizarrely, using basically exactly the same code except getWalletTokenTransfers instead results in a 200 - so must be on moralis end?

What is the version that works and what is the version that doesn’t work?

Can you try with 0x1 instead of eth?

This is bizarre, I just came back from a walk and just pressed fire again in Paw – and I received a 200 for token balances.

Alas, it was on moralis side. A list of all the error codes would be great.


Calling getWalletTokenBalances was not working, calling getWalletTokenTransfers was working with the same parameters.