metaplex-foundation / metaplex

A directory of what the Metaplex Foundation works on!
https://metaplex.com
Apache License 2.0
3.32k stars 6.26k forks source link

Failed to serialize or deserialize account data: Unknown #2306

Open web-full-stack-developer opened 8 months ago

web-full-stack-developer commented 8 months ago

I was creating spl token with metadata using createCreateMetadataAccountV3Instruction function of "@metaplex-foundation/mpl-token-metadata": "^2.5.2" I got error like SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Failed to serialize or deserialize account data: Unknown at Connection.sendEncodedTransaction (E:\02-08 (token-create-app)\mint\node_modules\@solana\web3.js\src\connection.ts:5921:13) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async Connection.sendRawTransaction (E:\02-08 (token-create-app)\mint\node_modules\@solana\web3.js\src\connection.ts:5880:20) at async Object.sendTransaction (E:\02-08 (token-create-app)\mint\node_modules\@metaplex-foundation\umi-rpc-web3js\src\createWeb3JsRpc.ts:327:25) { logs: [ 'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]', 'Program log: Error: BorshIoError', 'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 2755 of 200000 compute units', 'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: **Failed to serialize or deserialize account data: Unknown'** ] }

my script is

import { Keypair, clusterApiUrl, Connection, PublicKey, Transaction, sendAndConfirmTransaction, SystemProgram } from "@solana/web3.js";
import { createCreateMetadataAccountV3Instruction, PROGRAM_ID } from "@metaplex-foundation/mpl-token-metadata";
import { MINT_SIZE, TOKEN_PROGRAM_ID, createInitializeMintInstruction, getMinimumBalanceForRentExemptMint, getAssociatedTokenAddress, createAssociatedTokenAccountInstruction, createMintToInstruction } from '@solana/spl-token';
const connection = new Connection(clusterApiUrl('testnet'), 'confirmed');
import secret from './guideSecret.json';
const payer = Keypair.fromSecretKey(new Uint8Array(secret));
const run = async () => {
const mintKeypair = new PublicKey("GKaVDS9kJYkXMYqwbLMqK3au1nyp1HKhcGYRnzJ2ErKs");
const metaPDA = PublicKey.findProgramAddressSync(
[
Buffer.from("metadata"),
PROGRAM_ID.toBuffer(),
mintKeypair.toBuffer(),
],
PROGRAM_ID,
)[0];
console.log(metaPDA.toBase58());
const createMetadataInstruction = createCreateMetadataAccountV3Instruction(
{
metadata: metaPDA,
mint: mintKeypair,
mintAuthority: payer.publicKey,
payer: payer.publicKey,
updateAuthority: payer.publicKey,
systemProgram: SystemProgram.programId
},
{
createMetadataAccountArgsV3: {
data: {
name: "This is test",
symbol: "TTT",
uri: "",
creators: null,
sellerFeeBasisPoints: 0,
uses: null,
collection: null,
},
isMutable: false,
collectionDetails: null,
},
},
);
const createNewTokenTransaction = new Transaction().add(
createMetadataInstruction
);
sendAndConfirmTransaction(
connection,
createNewTokenTransaction,
[payer],
).then(signature => {
console.log('SIGNATURE', signature);
})
}
run();

This script was working well on devnet, was not working on testnet, mainnet-beta Please fix it for me

Tgcohce commented 2 months ago

You should check the transaction you are signing and if you are using .serialize() for the signed transaction.