1

I am using Node.js

I am trying to get NFT metada but getting this error:

file:///home/tiosam/sns-tw-bot/node_modules/@metaplex-foundation/js/dist/esm/plugins/nftModule/pdas.mjs:10
  return Pda.find(programId, [Buffer.from('metadata', 'utf8'), programId.toBuffer(), mint.toBuffer()]);
                                                                                          ^

TypeError: Cannot read properties of undefined (reading 'toBuffer')
    at findMetadataPda (file:///home/tiosam/sns-tw-bot/node_modules/@metaplex-foundation/js/dist/esm/plugins/nftModule/pdas.mjs:10:91)
    at Object.handle (file:///home/tiosam/sns-tw-bot/node_modules/@metaplex-foundation/js/dist/esm/plugins/nftModule/operations/findNftByMint.mjs:43:44)
    at Task.callback (file:///home/tiosam/sns-tw-bot/node_modules/@metaplex-foundation/js/dist/esm/plugins/operationModule/OperationClient.mjs:40:31)
    at file:///home/tiosam/sns-tw-bot/node_modules/@metaplex-foundation/js/dist/esm/utils/Task.mjs:58:50
    at Disposable.run (file:///home/tiosam/sns-tw-bot/node_modules/@metaplex-foundation/js/dist/esm/utils/Disposable.mjs:22:36)
    at Task.forceRun (file:///home/tiosam/sns-tw-bot/node_modules/@metaplex-foundation/js/dist/esm/utils/Task.mjs:47:23)
    at Task.run (file:///home/tiosam/sns-tw-bot/node_modules/@metaplex-foundation/js/dist/esm/utils/Task.mjs:29:19)
    at txInfo (file:///home/tiosam/sns-tw-bot/test.js:24:64)
    at file:///home/tiosam/sns-tw-bot/test.js:12:21
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Node.js v17.9.0

When using:

await metaplex.nfts().findByMint({tokenMint}).run();

My code:

import * as anchor from '@project-serum/anchor';
import { Metaplex } from "@metaplex-foundation/js";

const conn = new anchor.web3.Connection('PRIVATE RPC', 'confirmed');
const metaplex = new Metaplex(conn);

const txQuery = await conn.getTransaction('2Rgcsjea27NvvjVE3t68aKHCPmuq4zsat9uAaqoD6CMwTGF1n3EXu5kKXYtCq4XMgw6cTUsDVzXo136yGAj5MD5H', 'confirmed');

let accountIndexToken = txQuery.transaction.message.instructions[1].accounts[2];
let tokenMint = txQuery.transaction.message.accountKeys[accountIndexToken];
let nft = await metaplex.nfts().findByMint({tokenMint}).run();

1 Answer 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.