0

I'm trying to update metadata (logo, name) of solana token I have created. It is just for learning, nothing commercial.

Here is try catch that throws error:

try {
        const txid = await web3.sendAndConfirmTransaction(connection, tx, [myKeypair]);
        console.log(txid);

    } catch (error) {
        console.log(error);
    }

Error is:

SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: custom program error: 0x3f
    at Connection.sendEncodedTransaction (F:\Projekti\Crypto\FatBoyToken\node_modules\@solana\web3.js\src\connection.ts:5054:13)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Connection.sendRawTransaction (F:\Projekti\Crypto\FatBoyToken\node_modules\@solana\web3.js\src\connection.ts:5013:20)
    at async Connection.sendTransaction (F:\Projekti\Crypto\FatBoyToken\node_modules\@solana\web3.js\src\connection.ts:5001:12)
    at async Object.sendAndConfirmTransaction (F:\Projekti\Crypto\FatBoyToken\node_modules\@solana\web3.js\src\utils\send-and-confirm-transaction.ts:31:21)
    at async main (F:\Projekti\Crypto\FatBoyToken\main.ts:75:22) {
  logs: [
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]',
    'Program log: Instruction: Update Metadata Accounts v2',
    'Program log: Data type mismatch',
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 3723 of 200000 compute units',
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x3f'
  ]

connection is:

const connection = new web3.Connection("https://api.mainnet-beta.solana.com");

and tx is:

const tx = new web3.Transaction();

for myKeypar creatin I have used function:

export function loadWalletKey(keypairFile: string): web3.Keypair {
    const fs = require("fs");
    const loaded = web3.Keypair.fromSecretKey(
        new Uint8Array(JSON.parse(fs.readFileSync(keypairFile).toString())),
    );
    return loaded;
}

I am also new to TS/JS. I assume that 'Data type mismatch' needs to give me answer but I don't understand which data that is? And is there anything else that can give me error?

TylerH
  • 20,799
  • 66
  • 75
  • 101
NemanjaP
  • 1
  • 1

1 Answers1

0

Error message is saying "Error processing Instruction 0". you are not passing instruction. you have to define an instruction and add it to the transaction. chekc the example here

// Create Simple Transaction
let transaction = new web3.Transaction();

// Add an instruction to execute
transaction.add(
  web3.SystemProgram.transfer({
    fromPubkey: payer.publicKey,
    toPubkey: toAccount.publicKey,
    lamports: 1000,
  }),
);

// Send and confirm transaction
// Note: feePayer is by default the first signer, or payer, if the parameter is not set
await web3.sendAndConfirmTransaction(connection, transaction, [payer]);
Yilmaz
  • 35,338
  • 10
  • 157
  • 202
  • Thanks for answer but Im adding transaction: createCreateMetadataAccountV2Instruction or createUpdateMetadataAccountV2Instruction. Is it possible that I get error because I don't have Update Authority? – NemanjaP Nov 07 '22 at 23:03
  • @NemanjaP signers array correct? – Yilmaz Nov 07 '22 at 23:30
  • The problem was in the code. So I removed the if part and leave only the "create" part and it worked. Thank you for your help. :) – NemanjaP Nov 14 '22 at 17:57
  • @NemanjaP please post your answer so it may be helpful in the future for others – Yilmaz Nov 15 '22 at 01:43