400 and Invalid Function GetNFTs errors

I’m fairly new to interacting with blockchains so this could be something simple I’ve misunderstood, but I am getting 400 errors and ‘Invalid function: “getNFTs”’ errors. I’ve tried using some of the troubleshooting code samples posted on this forum to attempt to rule out an issue with my code but everything I’ve tried gives me the same errors. MetaMask connects and signs as I think it should.
Here’s the current code:

    <!-- Moralis SDK code -->
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>
    <script src="https://unpkg.com/moralis/dist/moralis.js"></script>
    <h1>Moralis Test</h1>

    <button id="btn-login">Moralis Login</button>
    <button id="btn-getnftbalances">Get NFT Balances</button>
    <button id="btn-logout">Logout</button>

      // connect to Moralis server
      Moralis.serverURL = "https://jok6y0o5mjko.usemoralis.com:2053/server";

      async function login() {
        let user = Moralis.User.current();
        if (!user) {
          user = await Moralis.Web3.authenticate();
        console.log("logged in user:", user);

      async function logOut() {
        await Moralis.User.logOut();
        console.log("logged out");

      async function getNFTBalances() {
        const options = {chain: 'binance smart chain', address: '0x90099da42806b21128a094c713347c7885af79e2'};
        const nfts = await Moralis.Web3.getNFTs(options);

      // bind button click handlers
      document.getElementById("btn-login").onclick = login;
      document.getElementById("btn-logout").onclick = logOut;
      document.getElementById("btn-getnftbalances").onclick = getNFTBalances;


And here is the console output:

moralis.js:21917 POST https://jok6y0o5mjko.usemoralis.com:2053/server/functions/getNFTs 400
dispatch @ moralis.js:21917
ajax @ moralis.js:21924
(anonymous) @ moralis.js:22028
Promise.then (async)
request @ moralis.js:22022
run @ moralis.js:427
run @ moralis.js:353
value @ moralis.js:5278
getNFTBalances @ test2.html:38
moralis.js:24018 Uncaught (in promise) Error: Invalid function: "getNFTs"
    at handleError (moralis.js:22050)
    at async HTMLButtonElement.getNFTBalances (test2.html:38)
_construct @ moralis.js:24018
Wrapper @ moralis.js:24422
(anonymous) @ moralis.js:8462
ParseError @ moralis.js:8513
handleError @ moralis.js:22050
async function (async)
getNFTBalances @ test2.html:38

The server is on 0.0.244 and I’ve tried redeploying it a few times (and each time I’ve been changing my Server URL and Application ID in the code) but that doesn’t seem to help.

Hey @kyleacct

We already checking this problem. Please don’t reload the server now :man_mechanic:

Use chain: 'bsc' instead of chain: 'binance smart chain'


Update your server. Now it should work correctly :man_mechanic:

Cool, that works now, thank you! Have a great day

1 Like