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

Fetching metaplex metadata for NFT #881

Open
EliasR01 opened this issue Mar 22, 2023 · 3 comments · May be fixed by #919
Open

Fetching metaplex metadata for NFT #881

EliasR01 opened this issue Mar 22, 2023 · 3 comments · May be fixed by #919
Assignees
Labels
bug Something isn't working library

Comments

@EliasR01
Copy link

Describe the bug
I'm trying to fetch the metadata for some NFTs, having the mint addresses:

NFT1: EDjAyUug32A6pqbxRKrQwGLGt5S7iXJDMPs3ZyVHerEH

NFT2: 3frcQsLMS3pYZGCGpKRXYeWhX5wq4HBXsuajnodporKY

Using the RPC client function

_solanaClient.rpcClient.getMetadata(
      mint: Ed25519HDPublicKey.fromBase58(data.parsed.info.mint),
      commitment: Commitment.finalized,
);

Function snippet

Future<dynamic> getFakeIDsInWallet(String wallet) async {
    final filters = [
      const ProgramDataFilter.dataSize(165),
      ProgramDataFilter.memcmpBase58(offset: 32, bytes: wallet),
    ];

    final accounts = await _solanaClient.rpcClient.getProgramAccounts(
      tokenAddress,
      encoding: Encoding.jsonParsed,
      filters: filters,
    );

    final List<Metadata> fakeIds = [];
    Metadata? fakeID;

    for (var account in accounts) {
      {
        final dynamic data = account.account.data;

        // data.parsed.info.mint contains the address of the NFTs listed above, inside the wallet received as parameter
        // replace it with the above addresses
        final metaplexMetadata = await _solanaClient.rpcClient.getMetadata(
          mint: Ed25519HDPublicKey.fromBase58(data.parsed.info.mint),
          commitment: Commitment.finalized,
        );

        print("Metadata: ${metaplexMetadata?.name}");
        print("Metadata: ${metaplexMetadata?.mint}");

        if (metaplexMetadata == null) return;

        fakeIds.add(metaplexMetadata);
      }
    }
  }

Expected behavior
Both NFTs should bring it's metaplex metadata

Additional context
NFT1 comes with the field name as an empty String, while NFT2 does have it's name

PD: Those NFTs are on devnet

Fetching with the Javascript @metaplex-foundation/js works well, I don't know what's going on here, if someone could give me a help

@EliasR01 EliasR01 added bug Something isn't working library labels Mar 22, 2023
@justinenerio justinenerio self-assigned this Mar 22, 2023
@justinenerio justinenerio linked a pull request Apr 4, 2023 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@justinenerio @EliasR01 and others