Hello I already read this question
But I don't know how to create the BlockheightBasedTransactionConfirmationStrategy object in JS as in that example TS is used.
I will like to get this code in JS:
const connection = new Connection("YOUR_RPC")
const tx = new Transaction()
const signature = await connection.sendRawTransaction(tx.serialize())
const latestBlockHash = await connection.getLatestBlockhash()
const confirmStrategy: BlockheightBasedTransactionConfirmationStrategy = {
blockhash: latestBlockHash.blockhash,
lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
signature: signature
}
const result = await connection.confirmTransaction(confirmStrategy)
EDIT 1:
I tried:
const sig = conn.sendRawTransaction(tx.serialize())
console.log(sig);
const latestBlockHash = conn.getLatestBlockhash();
const txConfirmation = conn.confirmTransaction({
blockhash: latestBlockHash.blockhash,
lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
signature: sig,
});
But got this error:
throw new Error('signature must be base58 encoded: ' + rawSignature);