8

I'm trying to update metadataAccount of an NFT. I'm using a web interface with Phantom Wallet.

Everything works fine, until when I approve the transaction I got this error

{
  code: -32003,
  message: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x2d
}

Depending on Phantom Errors: https://docs.phantom.app/integrating/errors This error is "Phantom does not recognize a valid transaction"

import { Connection, clusterApiUrl, PublicKey, Transaction } from '@solana/web3.js';
import { createUpdateMetadataAccountV2Instruction } from '@metaplex-foundation/mpl-token-metadata';
import store from './store';
const { wallet, sendTransaction } = useWallet();

const { nft } = store; // Metaplex NFT object.

const connection = new Connection(clusterApiUrl(cluster), 'finalized');

const accounts = {
  metadata: nft.metadataAccount.publicKey,
  updateAuthority: wallet.publicKey,
}

const args = {
  updateMetadataAccountArgsV2: {
    data: {
      name: 'XX',
      symbol: 'XX',
      uri: 'xxx',
      sellerFeeBasisPoints: 10,
      creators: [
        { address: new PublicKey("Hs7dqix1uH3e34uPhxD2gGHP1qDU5kq9Jokbo42GYcx8"), shares: 0, verified: true },
        { address: new PublicKey("6gcCoH2utP8to4i7FpkYyfhiGFRQ98cernumtkNGXLsz"), shares: 100, verified: false },
      ],
      collection: {
        key: new PublicKey('FzhgLSpK4nFYef59Wwx124QXoiqVgDTzMXT8T2DVYvns'),
        verified: false,
      },
      uses: {
        remaining: 1,
        total: 1,
        useMethod: 0
      }
    },
    updateAuthority: new PublicKey(new_authority), // new_autority from an input
    primarySaleHappened: true,
    isMutable: true,
  }
}

const updateMetadataAccount = createUpdateMetadataAccountV2Instruction(
  accounts,
  args
);

const transaction = new Transaction();
transaction.add(updateMetadataAccount);
const trx = await sendTransaction(transaction, connection);
console.log(trx);

1 Answer 1

5

In this case error code 0x2d its a Token Metadata custom error that means ShareTotalMustBe100: Share total must equal 100 for creator array (You can check a list of errors and the meaning of those errors here).

In your case the error is appearing because when you are setting the creator array you are providing a shares field instead of a share field, so you have to change this:

creators: [
        { address: new PublicKey("Hs7dqix1uH3e34uPhxD2gGHP1qDU5kq9Jokbo42GYcx8"), shares: 0, verified: true },
        { address: new PublicKey("6gcCoH2utP8to4i7FpkYyfhiGFRQ98cernumtkNGXLsz"), shares: 100, verified: false },
      ],

to this:

creators: [
        { address: new PublicKey("Hs7dqix1uH3e34uPhxD2gGHP1qDU5kq9Jokbo42GYcx8"), share: 0, verified: true },
        { address: new PublicKey("6gcCoH2utP8to4i7FpkYyfhiGFRQ98cernumtkNGXLsz"), share: 100, verified: false },
      ],

and that should fix the 0x2d error.

2
  • 2
    can you update this answer to clarify that 0x2d is a Token Metadata custom error in this case? any program can potentially have an error code 0x2s custom error
    – trent.sol
    Jul 18, 2022 at 19:09
  • 1
    @trent.sol done! and yeah this is completly true Jul 19, 2022 at 18:09

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.