1
transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
            //console.log(`transaction.recentBlockhash: ${transaction.recentBlockhash}`)

            // Sign the transaction
            transaction.sign(payer);
            console.log("sign")

            // Send the transaction
            let signature = await connection.sendRawTransaction(transaction.serialize());
            console.log("Transaction sent with signature:", signature);

            // Confirm the transaction
            let confirmation = await connection.confirmTransaction(signature, 'confirmed');
            console.log("Transaction confirmed:", confirmation);
            // const rep = await sendAndConfirmTransaction(connection, transaction, [payer])
            // console.log(rep)

Sometimes it times out in 30 seconds, and sometimes it takes more than ten seconds and then is confirmed successfully. Is there any way to improve the speed?

1
  • is there a noticable differrence when using the normal sendTransaction
    – Jimii
    Commented May 20 at 18:53

1 Answer 1

1

I would recommend using a private RPC provider like Helius or Triton if you are using the public RPC endpoint.

Even though raw transactions might seem reasonable when sending transactions, external factors such as latency, network load ....

3
  • 1
    I used helius to create a free key. Is this ok? I have already done this, but it still times out frequently.
    – shutw
    Commented May 21 at 6:35
  • Yes. The free key has limitations. It's also depends on what you're doing. If you are generating profit, get a dedicated RPC node from them. Ultra expensive but worth it IMO.
    – Jimii
    Commented May 21 at 8:09
  • Also, don't spam with tx happening one after the others add timeouts if you are calling txs continuosly
    – Jimii
    Commented May 21 at 8:10

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.