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
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.
It has changed. Here is how I do it. It gets the json file info you need to use the metadata.