Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on nfts().findAllByCreator(verifiedcreator) #241

Closed
LaniakeaSC4 opened this issue Aug 16, 2022 · 15 comments
Closed

Error on nfts().findAllByCreator(verifiedcreator) #241

LaniakeaSC4 opened this issue Aug 16, 2022 · 15 comments

Comments

@LaniakeaSC4
Copy link

LaniakeaSC4 commented Aug 16, 2022

When trying to get a collection using nfts().findAllByCreator(verifiedcreator) I get the following error;

Version 0.15.0

/app/node_modules/@solana/web3.js/lib/index.cjs.js:4909
callback(new Error(`${res.status} ${res.statusText}: ${text}`));
Error: 410 Gone:  {"jsonrpc":"2.0","error":{"code": 410, "message":"The RPC call or parameters have been disabled."}, "id": "73a0aec1-3805-4bf8-b121-40119a2eb8ac" }
at ClientBrowser.callServer (/app/node_modules/@solana/web3.js/lib/index.cjs.js:4909:18)

Using

const { Metaplex, keypairIdentity, bundlrStorage } = require("@metaplex-foundation/js")
const { Connection, clusterApiUrl, Keypair } = require("@solana/web3.js")

async function getMetaplexData(creator) {

const connection = new Connection(clusterApiUrl("mainnet-beta"));
    const wallet = Keypair.generate();

const metaplex = Metaplex.make(connection)
      .use(keypairIdentity(wallet))
      .use(bundlrStorage())

const nfts = await metaplex.nfts().findAllByCreator(creator).run();
    return nfts
} 

var collectionNFTs = await getMetaplexData('2UWNPgEto1x2TnBisJ814xdXKUQE5KFzypBNKPPjXz9b')
console.log(collectionNFTs)
@LaniakeaSC4
Copy link
Author

Just read in https://github.com/metaplex-foundation/js/releases/tag/js%2Fv0.15.0
That creator address should be passed as object. I have tried this but get the same error.

@PieterSpruijt
Copy link

I'm getting the same error too!

@ninnjak
Copy link

ninnjak commented Aug 16, 2022

@LaniakeaSC4 you need to pass creator in as an object like you say. But also you need to convert it to a public key like so:

const creator = new PublicKey("2UWNPgEto1x2TnBisJ814xdXKUQE5KFzypBNKPPjXz9b");

const nfts = await metaplex.nfts().findAllByCreator({ creator }).run();

findAllByCreator works fine on devnet, I believe mainnet-beta doesn’t allow some calls like this one based on how expensive they are.

Try using a private RPC.

Edit: Tested on private RPC and it works

@LaniakeaSC4
Copy link
Author

@LaniakeaSC4 you need to pass creator in as an object like you say. But also you need to convert it to a public key like so:

const creator = new PublicKey("2UWNPgEto1x2TnBisJ814xdXKUQE5KFzypBNKPPjXz9b");

const nfts = await metaplex.nfts().findAllByCreator({ creator }).run();

findAllByCreator works fine on devnet, I believe mainnet-beta doesn’t allow some calls like this one based on how expensive they are.

Try using a private RPC.

Edit: Tested on private RPC and it works

Thanks. Are there any reference examples of connecting to a private rpc?

@ninnjak
Copy link

ninnjak commented Aug 16, 2022

@LaniakeaSC4 you need to pass creator in as an object like you say. But also you need to convert it to a public key like so:

const creator = new PublicKey("2UWNPgEto1x2TnBisJ814xdXKUQE5KFzypBNKPPjXz9b");

const nfts = await metaplex.nfts().findAllByCreator({ creator }).run();

findAllByCreator works fine on devnet, I believe mainnet-beta doesn’t allow some calls like this one based on how expensive they are.
Try using a private RPC.
Edit: Tested on private RPC and it works

Thanks. Are there any reference examples of connecting to a private rpc?

You can just add the private RPC url when you setup the connection like this:

const connection = new Connection("my-private-rpc-url");

https://docs.metaplex.com/resources/rpc-providers

@LaniakeaSC4
Copy link
Author

Thanks, got that. I made a alchemyapi.io solana app to test this and although the alchemy app recieves the request, the returned result is empty?

My complete function;

async function getMetaplexData(creator) {

const connection = new Connection("https://solana-mainnet.g.alchemy.com/v2/mykey")
    const wallet = Keypair.generate();

    const metaplex = Metaplex.make(connection)
      .use(keypairIdentity(wallet))
      .use(bundlrStorage())
      
      var creatorkey = new PublicKey(creator);

    const nfts = await metaplex.nfts().findAllByCreator({creatorkey}).run();
    return nfts
}

API recieves

{"method":"getProgramAccounts","jsonrpc":"2.0","params":["metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",{"encoding":"base64","filters":[{"memcmp":{"offset":0,"bytes":"5"}},{"memcmp":{"offset":326,"bytes":"1"}}],"dataSlice":{"offset":33,"length":32}}],"id":"ac402039-eaa5-44bd-be9d-5eed563d5f49"}

API responds

{"jsonrpc":"2.0","result":[],"id":"ac402039-eaa5-44bd-be9d-5eed563d5f49"}

@ninnjak
Copy link

ninnjak commented Aug 16, 2022

You're forming the findAllByCreator input object incorrectly, the key should be creator.

My previous example used the shorthand way which may have confused you. Try this:

async function getMetaplexData(creator) {
    const connection = new Connection("https://solana-mainnet.g.alchemy.com/v2/mykey")
    const wallet = Keypair.generate();

    const metaplex = Metaplex.make(connection)
      .use(keypairIdentity(wallet))
      .use(bundlrStorage())
      
    const creatorkey = new PublicKey(creator);

    const nfts = await metaplex.nfts().findAllByCreator({ creator: creatorkey }).run();
    return nfts
}

Edit: Although after testing this properly on mainnet I only see empty array responses too, but it works fine on devnet 😕

@LaniakeaSC4
Copy link
Author

LaniakeaSC4 commented Aug 16, 2022

Edit: Although after testing this properly on mainnet I only see empty array responses too, but it works fine on devnet 😕

Hmmm... Me also... So what now? 😀

Edit: for clarity for future readers I assume you mean the input object should be { "creator" : creatorkey } and not { creator : creatorkey } as in, the object key should actually be "creator" and not my creator variable which is the verified creator address? (wow, that's a confusing sentence!)

Are you testing with my creator address or another? (just incase I got that wrong, I'm new-ish to all this)

@ninnjak
Copy link

ninnjak commented Aug 16, 2022

creator with or without the quotes makes no difference.

I just tried with a different RPC (https://www.quicknode.com/) and got a valid response with metadata. Using a different creator address with only 8 NFTs and that request took around 3 minutes.

The wallet address you provided in your example seems to timeout. Maybe that address has a lot of NFTs.

Checkout issues #196 and #47 that explains the limitations in more detail.

@LaniakeaSC4
Copy link
Author

creator with or without the quotes makes no difference.

I just tried with a different RPC (https://www.quicknode.com/) and got a valid response with metadata. Using a different creator address with only 8 NFTs and that request took around 3 minutes.

The wallet address you provided in your example seems to timeout. Maybe that address has a lot of NFTs.

Checkout issues #196 and #47 that explains the limitations in more detail.

Thanks for the info. If I could get this working with a private RPC, can I pass all the returned NFT metadata to .load() command as one blob (i.e. directly pass the result of const nfts = await metaplex.nfts().findAllByCreator({ creator: creatorkey }).run();? My initial testing suggests that .load() only accepts a single NFT.

@ninnjak
Copy link

ninnjak commented Aug 17, 2022

creator with or without the quotes makes no difference.
I just tried with a different RPC (https://www.quicknode.com/) and got a valid response with metadata. Using a different creator address with only 8 NFTs and that request took around 3 minutes.
The wallet address you provided in your example seems to timeout. Maybe that address has a lot of NFTs.
Checkout issues #196 and #47 that explains the limitations in more detail.

Thanks for the info. If I could get this working with a private RPC, can I pass all the returned NFT metadata to .load() command as one blob (i.e. directly pass the result of const nfts = await metaplex.nfts().findAllByCreator({ creator: creatorkey }).run();? My initial testing suggests that .load() only accepts a single NFT.

That's correct you can't pass all the NFTs to the load function. You would need to iterate the list of NFTs and call load on each one.

@LaniakeaSC4
Copy link
Author

creator with or without the quotes makes no difference.
I just tried with a different RPC (https://www.quicknode.com/) and got a valid response with metadata. Using a different creator address with only 8 NFTs and that request took around 3 minutes.
The wallet address you provided in your example seems to timeout. Maybe that address has a lot of NFTs.
Checkout issues #196 and #47 that explains the limitations in more detail.

Thanks for the info. If I could get this working with a private RPC, can I pass all the returned NFT metadata to .load() command as one blob (i.e. directly pass the result of const nfts = await metaplex.nfts().findAllByCreator({ creator: creatorkey }).run();? My initial testing suggests that .load() only accepts a single NFT.

That's correct you can't pass all the NFTs to the load function. You would need to iterate the list of NFTs and call load on each one.

@ninnjak is there any way to slow the API request rate? I don't necessarily need speed and could avoid these errors (although, they do all resolve successfully).

Screenshot_20220820-110729_Chrome

@ninnjak
Copy link

ninnjak commented Aug 21, 2022

@LaniakeaSC4 I think this is a little off topic based on the original question. But there are many ways to approach this (hard to say which is best without context). Here are a few ideas:

  1. Pay for the RPC to increase the request per second.
  2. Paginate the requests and call them in batches that don’t exceed the rate limits. e.g. paginate-nfts
  3. Add an artificial delay between each request, I've seen this done using setTimeout.

@lorisleiva
Copy link
Contributor

Hey all 👋 Closing this since @ninnjak did a great job at answering all the questions. Thank you for your help! ❤️

@cicoph
Copy link

cicoph commented Sep 19, 2022

Thanks, got that. I made a alchemyapi.io solana app to test this and although the alchemy app recieves the request, the returned result is empty?

My complete function;

async function getMetaplexData(creator) {

const connection = new Connection("https://solana-mainnet.g.alchemy.com/v2/mykey")
    const wallet = Keypair.generate();

    const metaplex = Metaplex.make(connection)
      .use(keypairIdentity(wallet))
      .use(bundlrStorage())
      
      var creatorkey = new PublicKey(creator);

    const nfts = await metaplex.nfts().findAllByCreator({creatorkey}).run();
    return nfts
}

API recieves

{"method":"getProgramAccounts","jsonrpc":"2.0","params":["metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",{"encoding":"base64","filters":[{"memcmp":{"offset":0,"bytes":"5"}},{"memcmp":{"offset":326,"bytes":"1"}}],"dataSlice":{"offset":33,"length":32}}],"id":"ac402039-eaa5-44bd-be9d-5eed563d5f49"}

API responds

{"jsonrpc":"2.0","result":[],"id":"ac402039-eaa5-44bd-be9d-5eed563d5f49"}

I think the problem is this, the method add a unnecessary filter in the RPC call, if you remove this it's works...
..... {"memcmp": { "offset":0, "bytes":"5" }}, .....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants