0

I wrote a function in typescript by using solana/web3.js. Sometimes, I received this error. I simply implement code following the doc of solana. I realized if I use sendRawTransaction, it will be better result, the failure percentage is quite lower than sendTransaction.

const amount = this.convertSOL2LAMPORT(request.amount).toNumber()
const transaction = new solanaWeb3.Transaction().add(
  solanaWeb3.SystemProgram.transfer({
    fromPubkey: signerKeyPair.publicKey,
    toPubkey: new solanaWeb3.PublicKey(request.to),
    lamports: amount,
  }),
)

const result = await this.provider.sendTransaction(
  transaction,
  [signerKeyPair],
  {
    /**
     * * Base on retry transaction fact
     * * https://solanacookbook.com/guides/retrying-transactions.html#facts
     */
    maxRetries: 5,
  },
)

P/s: I'm using third party api (which is Quicknode for testnet and GetBlock for mainnet).

2 Answers 2

0

Frompubkey and topubkey should be wallet address and you also need to give recent blockhash and fee payer to all the transaction object

2
  • I still dont understand. In following guide, the from_pub_key with be the fee payer, it's very clear in sample which solana team provided. But are there any difference between sendTransaction and sendRawTransaction will raise this error?
    – Lee Toan
    Commented Aug 17, 2022 at 16:20
  • @LeeToan Yes, there is a difference. Post your sendRawTransaction code in the original question. You said only sometimes you get the error, what are the conditions? Are you trying to send multiple rapidly?
    – Bryon M
    Commented Aug 18, 2022 at 6:40
0

I found a unoffical solution that send multiple transaction with the same hashTx. Many error returned but the success result responsed together. I thought this is potent

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Sep 28, 2022 at 10:37

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.