could anyone explain how to handle errors on transaction request (insufficient fund, account not found ),as the request on server is sent by wallet.

2 Answers 2


You can catch the error and parse it.


try { 
   // send transaction
} catch(e) {
  if (e.message.contains('insufficient fund')) {
    toast('insufficient fund')
  • The request is sent by the wallet to my server and my client is unware of this req,res . Feb 11, 2023 at 11:38
  • you can add this code either in your client code or server code. whoever is going to send the transaction to the network will throw an error if it fails.
    – vicyyn
    Feb 11, 2023 at 12:08
  • This response or error message will go the wallet that is scanned the QR and making the transaction, will wallet show this error , that's where my confusion is Feb 11, 2023 at 16:38

Error handling is included in the newer v1.1 spec of Solana Pay. Quote:

If the application responds with an HTTP client or server error in response to the POST or PUT operations, the wallet must consider the entire transaction request as failed.

Client and server errors may optionally be accompanied by a JSON body containing a UTF-8 string message field describing the nature of the error:


The wallet must display at least the first 80 characters of the message field to the user if it is included in the response.

So, you can send your error message in this format.

However, this is local to the wallet. There is a redirect field in the newer spec, but only for successful transactions:

Redirect URLs should only be followed if the transaction is successful.

Another problem: I don't know how widespread the adoption of this spec is. Note that v1 didn't include it.

My approach here would be to do all the checking on the server (custom checks or with simulateTransaction) and possibly inform other components if there's an error. You could send a dummy transaction in return, possibly using the message field for the error (even if it's meant for something else -- we've all been there).

  • thanks , I'll try that Mar 16, 2023 at 5:51

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.