js icon indicating copy to clipboard operation
js copied to clipboard

unable to update pNFT with rules set / need demo code for updating pNFTs once rule set

Open the-mercenaries-ltd opened this issue 2 years ago • 5 comments

According to the docs, we should be able to update pNFTs with something like:

await metaplex.nfts().update({
    nftOrSft,
    name: "My new NFT name",
    ruleSet: ruleSet.publicKey,
});

I already have Compatibility Rule Set assigned (AdH2Utn6Fus15ZhtenW4hZBQnvtLgM1YCW2MfVp7pYS5).

So I try simply using

await metaplex.nfts().update({
    nftOrSft,
    name: "My new NFT name",
});

But both of these code snippets give the error from the TokenMetadataProgram:

  logs: [
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]',
    'Program log: Instruction: Token Metadata Update',
    'Program log: Missing authorization rules account',
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 21619 of 200000 compute units',
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x8a'
  ]

I feel there must be a little more nuance needed to update a pNFT but after inspecting the codebase, I am unable to work it out.

This code might be going in the right direction as it gives a different error:

  await metaplex.nfts().update(
  {
    nftOrSft: nft,
    name: "My new NFT name",
    authorizationDetails: {
      rules: new PublicKey("AdH2Utn6Fus15ZhtenW4hZBQnvtLgM1YCW2MfVp7pYS5")
    }
  },
);

The error for this last snippet is

  logs: [
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]',
    'Program log: Instruction: Token Metadata Update',
    'Program log: Missing authorization rules program',
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 16299 of 200000 compute units',
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x96'
  ]

Does this make any sense to anyone?

Can somebody provide a better example code snippet?

the-mercenaries-ltd avatar Feb 18 '23 00:02 the-mercenaries-ltd

hi, how do you apply the changes you make in the pull request? I try to apply the changes you make by updating the code in node_modules/@metaplex-foundation/js but still got the same error.

postopororo avatar Feb 27 '23 03:02 postopororo

also looking for a sample code for this update. thanks

majin22 avatar Mar 06 '23 01:03 majin22

Having the same issue here

verata-veritatis avatar Apr 12 '23 21:04 verata-veritatis

did anyone solve this yet? Going crazy atm and need to get our App up&running again with metaplex.update()

fabianhenzler avatar May 05 '23 12:05 fabianhenzler

First, make sure that you've updated the Metaplex library to the latest version. Below is the code that I'm using to update the metadata uri.

await metaplex.nfts().update({
        nftOrSft: nft,
        uri: metadataUri,
        authorizationDetails: nft.programmableConfig?.ruleSet
          ? {
              rules: nft.programmableConfig?.ruleSet,
            }
          : undefined,
      });

danielmilner avatar May 05 '23 13:05 danielmilner