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)
}
}