Getting 400 bad req on any Web3API call on local devchain

Hello, I am getting a 400 anytime I try to use the Web3API, I am using hardhat local dev chain and am connected by proxy to the server but I cannot get anything to work. https://admin.moralis.io/web3Api queries work fine but anything from my react moralis app does not work.
authenticate() works fine with metamask
I am on Linux Mint as well if that matters.

import React, {createContext, useEffect, useState } from “react”;
import { useForm } from “react-hook-form”;
import { useMoralis,useMoralisWeb3Api, useMoralisWeb3ApiCall } from “react-moralis”
import {abi} from ‘…/abi/abi’

const CONTRACT_ADDRESS = ‘0xCD8a1C3ba11CF5ECfa6267617243239504a98d90’ //deploy to hardhat after compile then add contractaddress here
const contractAbi = abi.abi //exported abi for now

export const ContractContext = createContext();

export function ContractProvider(props) {

const [contract, setContract] = useState()

const options = {
    chain: "hardhat",
    address: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
  };

const {authenticate, logout,isInitialized, isAuthenticated,authError, hasAuthError,user, enableWeb3,isAuthenticating, isWeb3Enabled, Moralis, web3} = useMoralis()

const Web3API = useMoralisWeb3Api();

useEffect( ()=>{

if (isInitialized) {
    enableWeb3();
    setContract(new web3.eth.Contract(contractAbi, CONTRACT_ADDRESS))

    const getPrice = async () => {
      try{
        await Web3API.token.getTokenPrice({address: "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", chain: "bsc"})
      }catch(e){
        console.log(e)
      }
      
    }
    
    getPrice();
    
    
    
  }
}, [isInitialized, Moralis]);

if (!isInitialized) {
    return null;
  }

return (
    <ContractContext.Provider value={{contract}}>

        {props.children}

    </ContractContext.Provider>
)

}

can you also post your server url and application id?

Server URL: https://jatfccjcovh3.moralishost.com:2053/server

Application ID: 4S12Z6OWMk2IkfGcKr712xLVTldKoSt2jM2PXM0T

I have a ganache dev server that looks to work well:

Server URL: https://nmpybhwvmsji.moralishost.com:2053/server
Application ID: Pf8atloG7uNhe8ZSNmPYLVYubfflkRuvJdJHrlEZ

You can try with this one just to see if your code works fine.

I changed Moralis provider to the URL and App ID you provided and im still getting same error :’(

okay im trying

const getPrice = async () => {
try{
const transactions = await Web3API.account.getTransactions();
console.log(transactions)
}catch(e){
console.log(e)
}

    }
    
    getPrice();

and I am getting a response with ur ganache server, but I tried with my own server and still getting 400

Ok, it looks like your server has some problems, we will check.

when visiting https://admin.moralis.io/web3Api, can you copy your API key from Copy API key or see it when you make a simple request in the curl command?
asking because when visiting https://admin.moralis.io/web3Api it should generate your API key if it was not generated before, and without an API key generated on your account the web3api requests will not work

I do have an API key on my account

curl -X 'GET' \
  'https://deep-index.moralis.io/api/v2/0x159feb32c2374de0c28e426dd572385bda5a9c27?chain=eth&subdomain=https%3A%2F%2Fjatfccjcovh3.moralishost.com%3A2053%2Fserver' \
  -H 'accept: application/json' \
  -H 'X-API-Key: gZraArHo1dXfZ5Qpl9QAeU8FPqZqBToBvKbjzWej4zfh3wylLRXiIzqQfL7JYvOv'

Now it looks like your server works fine for web3api requests.

no that was from https://admin.moralis.io/web3Api , still cannot do any requests on my react moralis frontend

Moralis.Web3API.token.getTokenPrice({address: "0xe9e7cea3dedca5984780bafc599bd69add087d56", chain: "bsc"}) looks to work now for your server.

okay it seems to not work if I try to use my local hardhat chain. I have tried chain:“localdevchain”, “hardhat”, “dev” and all are getting 400 response. what params should I put for chain when I try to get a balance of a address on my local chain for example?

For local devchain not all web3api functions work, and for now I’ll have to find out how to use those few that should work. I tried yesterday with various options for chain and didn’t work for me either. I’ll come back when I’ll found out what parameters should be used for a local devchain for web3api.

hello any update on this? I was hoping webAPI would work for a local devchain as testing smartcontracts on testnet takes much more time

No new update for now.

I have same issue. Local dev server and error on NFTBalance:

{“code”:141,“error”:“Invalid chain”}

web3api still doesn’t work with local devchain

Oh, do you have any estimate when this will work?

You could use web3api with a testnet or mainnet network, you don’t have to change the server.

I don’t have an estimate for when web3api will work with local dev chain. We don’t expect that in the near future.