skip to Main Content

I try to get Solana Nfts for owner with Metaplex Javascript SDK but the request gives me the following response:

Error: 410 Gone: {"jsonrpc":"2.0","error":{"code": 410, "message":"The RPC call or parameters have been disabled."}

I use React-js framework with hooks.
I can’t migrate to Next-js.

This is the function that i call. It’s a standard function and I copied it from Web:

const getNftsForOwnerByAddressAndChainNameSolana = async (address, chainName) => {
  const connection = new Connection(clusterApiUrl(chainName), "confirmed");
  const keypair = Keypair.generate();
  
  const metaplex = new Metaplex(connection);
  metaplex.use(keypairIdentity(keypair));
  
  const owner = new PublicKey(address);
  const allNFTs = await metaplex.nfts().findAllByOwner({ owner });
  
  console.log(allNFTs);
}

Where
chainName = "mainnet-beta";
and address is a real Solana address, that I can explore on official Solana website.

This is the response:

Error: 410 Gone: {"jsonrpc":"2.0","error":{"code": 410, "message":"The RPC call or parameters have been disabled."}

I tried to connect to the cluster "devnet". so, chainName = "devnet";
The request has a success response (empty array, no nfts) and the program works, but i need to connect to the cluster "mainnet-beta", because nfts are there.

I also tried this function, that uses Alchemy Api Key:

const getNftsForOwnerByAddressAndChainNameSolana = async (address) => {
  const rpc = "https://solana-mainnet.g.alchemy.com/v2/<ALCHEMY_API_KEY>";
  const connection = new Connection(rpc, "confirmed");
  const keypair = Keypair.generate();

  const metaplex = new Metaplex(connection);
  metaplex.use(keypairIdentity(keypair));

  const owner = new PublicKey(address);
  const allNFTs = await metaplex.nfts().findAllByOwner({ owner });
  console.log(allNFTs);
}

And it returns an empty array.

You can see that there are nfts on mainnet-beta cluster:
https://explorer.solana.com/address/5VRrCiaczvcHUoRUFz7ZXzR1zpGSCBbU7rndFRYdAFYC/tokens

I searched a lot on web but i didn’t find a solution.

How to solve this? Is it possible?

2

Answers


  1. Your code is most likely not even wrong.

    410 Gone means that the RPC that you are using is not offering the function call that findAllByOwner is using.

    Please try using a different RPC to solve this. E.g. Quicknode and extrnode are working fine for me.

    Login or Signup to reply.
  2. It has changed. Here is how I do it. It gets the json file info you need to use the metadata.

    import { useConnection, useWallet } from "@solana/wallet-adapter-react";
    import { Metaplex, walletAdapterIdentity, FindNftsByOwnerOutput, Metadata, JsonMetadata } from "@metaplex-foundation/js";
    import { FC, useEffect, useState } from "react";import Container from "../Container/Container";
    import NFT from "../NFT/OPENNFTCard"
    
    export const BagGrabber: FC = () => {
      const [nftData, setNftData] = useState<JsonMetadata[]>()
      const [selectedNft, setSelectedNft] = useState<Metadata>();
      const { connection } = useConnection();
      const wallet = useWallet();
      const metaplex = Metaplex.make(connection).use(walletAdapterIdentity(wallet));
    
      // fetch nfts
      const fetchNfts = async () => {
        if (!wallet.connected) {
          return
        }
    
        // fetch NFTs for connected wallet
        const NFTs = await metaplex.nfts().findAllByOwner({
          owner: metaplex.identity().publicKey
      });
    
         // fetch off chain metadata for each NFT
         let counter: number = NFTs.length;
         console.log("counter: "+counter);
    
        let nftData = [] as unknown as JsonMetadata[];
        let counterI= 0;
        for (var i in NFTs){
        console.log(NFTs[i].uri);
        counterI+=1;
          let fetchResult = await fetch(NFTs[i].uri)
          let json = await fetchResult.json()
          nftData.push(json)
        }
    
        // set state
        setNftData(nftData);
        console.log(nftData);
      }
    
      // fetch nfts when connected wallet changes
      useEffect(() => {
        fetchNfts()
      }, [wallet])
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search