[SOLVED] Error: Solana API error while calling /account/:network/:address/balance

import { useEffect } from ‘react’
import { useMoralisSolanaApi } from ‘react-moralis’
export default function Dashboard({logout, user}) {
let walletAddress = user.get(‘solAddress’)
let walletUsername = user.get(‘username’)
let SolanaAPI = useMoralisSolanaApi()
useEffect(() =>{
const fetchData = async() => {
try {
let result = await SolanaAPI.account.balance({
network: ‘mainnet’,
address: walletAddress
})
console.log(result)
} catch (error) {
console.log(error)
}
}
fetchData()
},[])
}

This is the error…
POST https://bttj0tfugmlu.usemoralis.com:2053/server/functions/sol-balance 400
dispatchXhrRequest @ xhr.js?1a5c:210

Dashboard.js?44ef:22 Error: Solana API error while calling /account/:network/:address/balance
at Function.eval (MoralisSolanaApi.js?8f56:238:1)
at tryCatch (runtime.js?c56e:63:16)
at Generator.invoke [as _invoke] (runtime.js?c56e:294:1)
at Generator.eval [as throw] (runtime.js?c56e:119:1)
at asyncGeneratorStep (asyncToGenerator.js?c39e:5:1)
at _throw (asyncToGenerator.js?c39e:31:1)

if you try it directly from the admin interface then it works? (with those specific parameters that you try there)

https://admin.moralis.io/web3Api

I am using Solana API. I think i used all the parameters correctly but it shows [Error: Solana API error while calling /account/:network/:address/balance]

There is no Solana Chain in the Add New Mainnet Server Settings. There is only ETH, MATIC, BSC, AVAX, FTM

What is the correct settings for Solana Mainnet?

I sent you the wrong url, try on this url: https://admin.moralis.io/solanaApi

I already using it, i am implementing it using react. but i think there’s a problem on mainnet server. in getting Solana Balance

can you give example of parameters where it doesn’t work in that admin interface?

https://bttj0tfugmlu.usemoralis.com:2053/server/functions/sol-balance

It is now working, I just updated and restart the server.
image

1 Like

I am now getting the values. This is solved.

image