metaplex-foundation / js

A JavaScript SDK for interacting with Metaplex's programs
357 stars 182 forks source link

Getting an error `InstructionPackError: Failed to pack instruction data` when trying to create a new NFT #148

Closed nikhilasrani closed 2 years ago

nikhilasrani commented 2 years ago

Hey folks, I'm getting an error when trying to run const { nft } = await metaplex.nfts().create({ uri }); The upload metadata step works fine and produces a uri with metadata that is identical to the ones that were working with the create NFT step before.

But when I run the above code, I get the following error

ParsedProgramError [MetaplexError]: TokenMetadataProgram > Failed to pack instruction data

Source: Program > TokenMetadataProgram [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s] Problem: The program [TokenMetadataProgram] at address [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s] raised an error of code [1] that translates to "Failed to pack instruction data". Solution: Check the error message provided by the program. Caused By: InstructionPackError: Failed to pack instruction data at RpcClient.parseProgramError (/Users/nikhilasrani/Developer/node_modules/@metaplex-foundation/js/dist/cjs/plugins/rpcModule/RpcClient.cjs:188:28) at RpcClient.sendTransaction (/Users/nikhilasrani/Developer/node_modules/@metaplex-foundation/js/dist/cjs/plugins/rpcModule/RpcClient.cjs:52:18) ... 6 lines matching cause stack trace ... at async createTableJSNext (/Users/nikhilasrani/Developer/services/table.service.js:209:21) at async Object.createTable (/Users/nikhilasrani/Developer/services/table.service.js:120:5) { key: 'metaplex.errors.program.parsed_program_error', title: 'TokenMetadataProgram > Failed to pack instruction data', problem: 'The program [TokenMetadataProgram] at address [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s] raised an error of code [1] that translates to "Failed to pack instruction data".', solution: 'Check the error message provided by the program.', source: 'program', sourceDetails: 'TokenMetadataProgram [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s]', cause: InstructionPackErrorError: Failed to pack instruction data`

The package versions I am using are "@solana/web3.js": "^1.41.3", "@metaplex-foundation/js": "^0.11.5"

lorisleiva commented 2 years ago

Hi there 👋 Thanks for raising this. I'll look into this asap. 🙂

lorisleiva commented 2 years ago

I'm afraid I can reproduce this issue. Would you be able to provide a public repository with the minimum amount of code to reproduce this issue?

nikhilasrani commented 2 years ago

hey @lorisleiva, I figured out the problem. It's rather quite silly, I think the this error starting showing up when we had an empty wallet/ no Solana balance to fund the creation of the NFT.

Once I added some SOL to my wallet, it began working as expected. Thank you for your prompt response and support. I really appreciate it.

Closing this issue with this comment so that maybe it can help others who face the same issue.

mikemaccana commented 1 year ago

@nikhilasrani Thanks for putting in your solution - it certainly helped me! I think the issue should remain open though as Failed to pack instruction data doesn't really help metaplex developers know the cause of the issue is an insufficient balance. Likewise other Solana apps - SPL, web3, etc. - simply say insufficient balance in this scenario.

Version is @metaplex-foundation/js@0.15.0 - will try and see if this occurs on a newer version but have some issues running 0.17 so far due to some http polyfilling.

/home/mike/Code/portal/wallet/node_modules/@metaplex-foundation/js/src/plugins/rpcModule/RpcClient.ts:302
      ? new ParsedProgramError(program, resolvedError)
        ^

MetaplexError: TokenMetadataProgram > Failed to pack instruction data
>> Source: Program > TokenMetadataProgram [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s]
>> Problem: The program [TokenMetadataProgram] at address [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s] raised an error of code [1] that translates to "Failed to pack instruction data".
>> Solution: Check the error message provided by the program.

Caused By: InstructionPackError: Failed to pack instruction data

    at parseProgramError (/home/mike/Code/portal/wallet/node_modules/@metaplex-foundation/js/src/plugins/rpcModule/RpcClient.ts:302:9)
    at RpcClient.sendTransaction (/home/mike/Code/portal/wallet/node_modules/@metaplex-foundation/js/src/plugins/rpcModule/RpcClient.ts:87:18)
    ... 6 lines matching cause stack trace ...
    at null.mintIdentityToken (/home/mike/Code/portal/wallet/src/backend/identity-tokens.ts:73:24)
    at null.mintAndTransferIdentityToken (/home/mike/Code/portal/wallet/src/backend/identity-tokens.ts:103:25) {
  key: 'metaplex.errors.program.parsed_program_error',
  title: 'TokenMetadataProgram > Failed to pack instruction data',
  problem: 'The program [TokenMetadataProgram] at address [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s] raised an error of code [1] that translates to "Failed to pack instruction data".',
  solution: 'Check the error message provided by the program.',
  source: 'program',
  sourceDetails: 'TokenMetadataProgram [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s]',
  cause: /home/mike/Code/portal/wallet/node_modules/@metaplex-foundation/js/src/plugins/nftModule/plugin.ts:70
          cusper.errorFromProgramLogs(error.logs, false),
                 ^

  InstructionPackError: Failed to pack instruction data
      at error (/home/mike/Code/portal/wallet/node_modules/@metaplex-foundation/js/src/plugins/nftModule/plugin.ts:70:16)
      at parseProgramError (/home/mike/Code/portal/wallet/node_modules/@metaplex-foundation/js/src/plugins/rpcModule/RpcClient.ts:299:35)
      at RpcClient.sendTransaction (/home/mike/Code/portal/wallet/node_modules/@metaplex-foundation/js/src/plugins/rpcModule/RpcClient.ts:87:18)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at RpcClient.sendAndConfirmTransaction (/home/mike/Code/portal/wallet/node_modules/@metaplex-foundation/js/src/plugins/rpcModule/RpcClient.ts:117:23)
      at TransactionBuilder.sendAndConfirm (/home/mike/Code/portal/wallet/node_modules/@metaplex-foundation/js/src/utils/TransactionBuilder.ts:189:22)
      at Object.handle (/home/mike/Code/portal/wallet/node_modules/@metaplex-foundation/js/src/plugins/nftModule/operations/createNft.ts:132:20)
      at null.<anonymous> (/home/mike/Code/portal/wallet/node_modules/@metaplex-foundation/js/src/utils/Task.ts:82:23)
      at Disposable.run (/home/mike/Code/portal/wallet/node_modules/@metaplex-foundation/js/src/utils/Disposable.ts:34:14)
      at null.mintIdentityToken (/home/mike/Code/portal/wallet/src/backend/identity-tokens.ts:73:24) {
    code: 1
  },
  logs: undefined,
  program: {
    name: 'TokenMetadataProgram',
    address: PublicKey {
      _bn: BN {
        negative: 0,
        words: [
          66595142, 28602112,
          64705691, 30173827,
          22591596, 46215411,
          30746614, 32576738,
          28435409,   187417,
                 0
        ],
        length: 10,
        red: null
      }
    },
    errorResolver: [Function: errorResolver],
    gpaResolver: [Function: gpaResolver]
  }
}