1

**this is the error i am facing while creating the token **

WalletSendTransactionError: Unexpected error
at StandardWalletAdapter.sendTransaction (adapter.js:224:23)
at async Object.eval [as sendTransaction] (WalletProviderBase.js:161:16)

this is the code

const transaction = new Transaction().add(
      SystemProgram.createAccount({
        fromPubkey: wallet.publicKey,
        newAccountPubkey: mintkeyPair.publicKey,
        space: MINT_SIZE,
        lamports,
        programId: TOKEN_2022_PROGRAM_ID,
      }),
      createInitializeMetadataPointerInstruction(
        mintkeyPair.publicKey,
        wallet.publicKey,
        mintkeyPair.publicKey,
        TOKEN_2022_PROGRAM_ID
      ),
      createInitializeMintInstruction(
        mintkeyPair.publicKey,
        decimals,
        wallet.publicKey,
        null,
        TOKEN_2022_PROGRAM_ID
      ),
      createInitializeInstruction({
        programId: TOKEN_2022_PROGRAM_ID,
        mint: mintkeyPair.publicKey,
        metadata: mintkeyPair.publicKey,
        name: metaData.name,
        symbol: metaData.symbol,
        uri: metaData.uri,
        mintAuthority: wallet.publicKey,
        updateAuthority: wallet.publicKey,
      })
    );

    

    transaction.feePayer = wallet.publicKey;
    transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
    transaction.sign(mintkeyPair);

    console.log(transaction)

    const signature = await wallet.sendTransaction(transaction, connection, { preflightCommitment: 'processed' });
    await connection.confirmTransaction(signature, 'processed');

repo link:link

1
  • 1
    could you set {skipPreflight: true} and share an explorer link to the failing IX
    – Jimii
    Commented Sep 12 at 7:48

1 Answer 1

0

This is a guess, but MINT_SIZE is probably not enough to cover for the base mint + metadata pointer extension + metadata extension, or there aren't enough lamports passed in to cover rent-exemption when the metadata is initialized.

Feel free to start from the metadata example at https://github.com/solana-labs/solana-program-library/blob/master/token/js/examples/metadata.ts and customize from there.

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.