1977
1977

Reputation: 2930

Should I do Solana transactions synchronously in my apis?

So I know that compared to most more decentralized blockchains that Solana is fast.

Still, the question I have is whether I should implement my transactions asynchronously off of a queue - so that I can retry failures if something fails etc

This gets further complicated for example if I am using metaplex to create a token with associated metadata etc as it involves 2 transactions: 1 to create the token and another to create the token-metadata for the token

Upvotes: 0

Views: 378

Answers (1)

Jon C
Jon C

Reputation: 8472

You're absolutely encouraged to retry transactions as appropriate. Here is an excerpt from the Solana Cookbook which gives the TLDR for retrying:

  • RPC nodes will attempt to rebroadcast transactions using a generic algorithm
  • Application developers can implement their own custom rebroadcasting logic
  • Developers should take advantage of the maxRetries parameter on the sendTransaction JSON-RPC method
  • Developers should enable preflight checks to raise errors before transactions are submitted
  • Before re-signing any transaction, it is very important to ensure that the initial transaction’s blockhash has expired

You can read the full source at https://solanacookbook.com/guides/retrying-transactions.html

Upvotes: 1

Related Questions