1

I'm totally new to solana so I'm following the 2023 bootcamp. Episode 1 has a repo you follow with the devrel, which starts with quest 1. He runs it fine in the video but I've encountered several problems. I am a newb mostly so I'm not exactly sure what's going on. First is the warning I would keep getting from getMinimumBalanceForRentExemption. I tried hard coded values similar to what I saw in the video but the error after still gets thrown. The actual error is:

throw new SendTransactionError({

            ^
SendTransactionError: Simulation failed. 
Message: Invalid params: unknown variant `single`, expected one of `processed`, `confirmed`, `finalized`.. 

Catch the `SendTransactionError` and call `getLogs()` on it for full details.

I can't find anything specific to this error, does anyone have any context? I think every quest in the episode uses the account that this TX is supposed to create so I can't continue working along the video

Here is the code from the file I'm trying to run:

// generate a new, random address to create on chain
  const keypair = Keypair.generate();

  console.log("New keypair generated:", keypair.publicKey.toBase58());

  // on-chain space to allocated (in number of bytes)
  const space = 0;

  const lamports = await connection.getMinimumBalanceForRentExemption(space);
  

  console.log("Total lamports:", lamports);

  // create this simple instruction using web3.js helper function
  const createAccountIx = SystemProgram.createAccount({
    // `fromPubkey` - this account will need to sign the transaction
    fromPubkey: payer.publicKey,

    // `newAccountPubkey` - the account address to create on chain
    newAccountPubkey: keypair.publicKey,

    // lamports to store in this account
    lamports,

    // total space to allocate
    space,

    // the owning program for this account
    programId: SystemProgram.programId,
  });

  // get the latest recent blockhash
  let recentBlockhash = await connection.getLatestBlockhash().then(res => res.blockhash);

  // create a message (v0)
  const message = new TransactionMessage({
    payerKey: payer.publicKey,
    recentBlockhash,
    instructions: [createAccountIx],
  }).compileToV0Message();

  // create a versioned transaction using the message
  const tx = new VersionedTransaction(message);

  tx.sign([payer, keypair]);

  console.log("tx after signing:", tx);

  // actually send the transaction
  try{
    const sig = await connection.sendTransaction(tx);
    console.log("Transaction completed.");
    console.log(explorerURL({ txSignature: sig }));
    
  }
  catch (error: any) {

    console.error("Transaction FAILED", error);
    if (error.logs) {
      console.error("Transaction logs: ", error.logs)
    }
    }
3
  • 1
    Could you give some more of the code that you're writing?
    – Jacob Creech
    Commented Oct 15 at 2:47
  • @JacobCreech Just added the code to the post for reference, thank you for the tip! Commented Oct 15 at 14:49
  • @JacobCreech I also just saw that the Solana foundation released a new 2024 bootcamp that you're in! Thanks for taking the time to make it! Going to use that instead since it is the most up to date tutorial available Commented Oct 15 at 16:37

1 Answer 1

1

After doing some digging I found that sendTransaction does not handle versioned messages well. I had to first serialize my transaction, then specify the preflightCommitment since it kept defaulting to "single" when it should have defaulted to "finalized". I then used sendRawTransaction instead and it worked.

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.