anza-xyz / solana-pay

A new standard for decentralized payments.
https://solanapay.com
Apache License 2.0
1.29k stars 450 forks source link

Specify Solana Pay transaction request error handling #150

Open samheutmaker opened 2 years ago

samheutmaker commented 2 years ago

The current Solana Pay standard does not formally specify how dapps should pass error messages to a wallet during a transaction request. Each wallet handles errors differently, with most wallets simply informing the user the request failed but offering no other context. This results in degraded UX and unnecessary overhead for developers as they are forced to use work-arounds (like sending memo transactions along with a message in the response) that are far from perfect and not documented.

This is an attempt to standardize how error messages are sent from dapps and displayed in wallets by making two simple changes to the specification. The changes are:

  1. The transaction field in the response object should be nullable. The following response should be considered valid, and the message should be displayed in the wallet.
    {
    "transaction": null,
    "message": "This QR Code is only available between 1-5pm UTC"
    }
  2. Wallets should always display at least the first 80 characters of a non-null message field. The number of characters currently displayed varies from wallet to wallet making it difficult for dapps to respond with appropriately sized messaged. For example, Phantom iOS truncates the message field with an ellipsis depending on screen size. Solflare and Glow both display the entire message. While we generally don't want to be overly prescriptive in how wallets behave, adding this constraint will improve the developer experience and ultimately result in better Solana Pay applications.

PR for this work is #151.

All feedback is welcome. I am available on telegram @samhogan for questions or comments.