Summary
A standard protocol to encode Solana transaction requests within URLs to enable payments and other use cases. This standard draws inspiration from BIP 21 and EIP 681.Motivation
A standard URL protocol for requesting native SOL transfers, SPL Token transfers, and Solana transactions allows for a better user experience across apps and wallets in the Solana ecosystem. These URLs may be encoded in QR codes or NFC tags, or sent between users and applications to request payment and compose transactions. Applications should ensure that a transaction has been confirmed and is valid before they release goods or services being sold, or grant access to objects or events. Mobile wallets should register to handle the URL scheme to provide a seamless yet secure experience when Solana Pay URLs are encountered in the environment. By standardizing a simple approach to solving these problems, we ensure basic compatibility of applications and wallets so developers can focus on higher level abstractions.Specification: Transfer Request
A Solana Pay transfer request URL describes a non-interactive request for a SOL or SPL Token transfer.Recipient
A singlerecipient field is required as the pathname. The value must be the
base58-encoded public key of a native SOL account. Associated token accounts
must not be used.
Instead, to request an SPL Token transfer, the spl-token field must be used to
specify an SPL Token mint, from which the associated token address of the
recipient must be derived.
Amount
A singleamount field is allowed as an optional query parameter. The value
must be a non-negative integer or decimal number of “user” units. For SOL,
that’s SOL and not lamports. For tokens, use
uiAmountString and not amount.
0 is a valid value. If the value is a decimal number less than 1, it must
have a leading 0 before the .. Scientific notation is prohibited.
If a value is not provided, the wallet must prompt the user for the amount. If
the number of decimal places exceed what’s supported for SOL (9) or the SPL
Token (mint specific), the wallet must reject the URL as malformed.
SPL Token
A singlespl-token field is allowed as an optional query parameter. The value
must be the base58-encoded public key of an SPL Token mint account.
If the field is provided, the
Associated Token Account
convention must be used, and the wallet must include a TokenProgram.Transfer
or TokenProgram.TransferChecked instruction as the last instruction of the
transaction.
If the field is not provided, the URL describes a native SOL transfer, and the
wallet must include a SystemProgram.Transfer instruction as the last
instruction of the transaction instead.
The wallet must derive the ATA address from the recipient and spl-token
fields. Transfers to auxiliary token accounts are not supported.
Reference
Multiplereference fields are allowed as optional query parameters. The values
must be base58-encoded 32 byte arrays. These may or may not be public keys, on
or off the curve, and may or may not correspond with accounts on Solana.
If the values are provided, the wallet must include them in the order provided
as read-only, non-signer keys to the SystemProgram.Transfer or
TokenProgram.Transfer/TokenProgram.TransferChecked instruction in the
payment transaction. The values may or may not be unique to the payment request,
and may or may not correspond to an account on Solana.
Because Solana validators index transactions by these account keys, reference
values can be used as client IDs (IDs usable before knowing the eventual payment
transaction). The
getSignaturesForAddress RPC method
can be used locate transactions this way.
Label
A singlelabel field is allowed as an optional query parameter. The value must
be a
URL-encoded
UTF-8 string that describes the source of the transfer request.
For example, this might be the name of a brand, store, application, or person
making the request. The wallet should
URL-decode
the value and display the decoded value to the user.
Message
A singlemessage field is allowed as an optional query parameter. The value
must be a
URL-encoded
UTF-8 string that describes the nature of the transfer request.
For example, this might be the name of an item being purchased, an order ID, or
a thank you note. The wallet should
URL-decode
the value and display the decoded value to the user.
Memo
A singlememo field is allowed as an optional query parameter. The value must
be a
URL-encoded
UTF-8 string that must be included in an SPL Memo
instruction in the payment transaction.
The wallet must
URL-decode
the value and should display the decoded value to the user. The memo will be
recorded by validators and should not include private or sensitive information.
If the field is provided, the wallet must include a MemoProgram instruction as
the second to last instruction of the transaction, immediately before the SOL or
SPL Token transfer instruction, to avoid ambiguity with other instructions in
the transaction.
Examples
URL describing a transfer request for 1 SOL
URL describing a transfer request for 0.01 USDC
URL describing a transfer request for SOL (user prompted for amount)
Specification: Transaction Request
A Solana Pay transaction request URL describes an interactive request for any Solana transaction.Link
A singlelink field is required as the pathname. The value must be a
conditionally
URL-encoded
absolute HTTPS URL.
If the URL contains query parameters, it must be URL-encoded. Protocol query
parameters may be added to this specification. URL-encoding the value prevents
conflicting with protocol parameters.
If the URL does not contain query parameters, it should not be URL-encoded. This
produces a shorter URL and a less dense QR code.
In either case, the wallet must
URL-decode
the value. This has no effect if the value isn’t URL-encoded. If the decoded
value is not an absolute HTTPS URL, the wallet must reject it as malformed.
GET Request
The wallet should make an HTTPGET JSON request to the URL. The request should
not identify the wallet or the user.
The wallet should make the request with an
Accept-Encoding header,
and the application should respond with a
Content-Encoding header
for HTTP compression.
The wallet should display the domain of the URL as the request is being made.
GET Response
The wallet must handle HTTP client error, server error, and redirect responses. The application must respond with these, or with an HTTPOK JSON response with
a body of:
<label> value must be a UTF-8 string that describes the source of the
transaction request. For example, this might be the name of a brand, store,
application, or person making the request.
The <icon> value must be an absolute HTTP or HTTPS URL of an icon image. The
file must be an SVG, PNG, or WebP image, or the wallet must reject it as
malformed.
The wallet should not cache the response except as instructed by
HTTP caching
response headers.
The wallet should display the label and render the icon image to user.
POST Request
The wallet must make an HTTPPOST JSON request to the URL with a body of:
<account> value must be the base58-encoded public key of an account that
may sign the transaction.
The wallet should make the request with an
Accept-Encoding header,
and the application should respond with a
Content-Encoding header
for HTTP compression.
The wallet should display the domain of the URL as the request is being made. If
a GET request was made, the wallet should also display the label and render
the icon image from the response.
POST Response
The wallet must handle HTTP client error, server error, and redirect responses. The application must respond with these, or with an HTTPOK JSON response with
a body of:
<transaction> value must be a base64-encoded
serialized transaction.
The wallet must base64-decode the transaction and
deserialize it.
The application may respond with a partially or fully signed transaction. The
wallet must validate the transaction as untrusted.
Empty Signatures
If the transactionsignatures
are empty:
- The application should set the
feePayerto theaccountin the request, or the zero value (new PublicKey(0)ornew PublicKey("11111111111111111111111111111111")). - The application should set the
recentBlockhashto the latest blockhash, or the zero value (new PublicKey(0).toBase58()or"11111111111111111111111111111111"). - The wallet must ignore the
feePayerin the transaction and set thefeePayerto theaccountin the request. - The wallet must ignore the
recentBlockhashin the transaction and set therecentBlockhashto the latest blockhash.
Non-empty Signatures
If the transactionsignatures
are nonempty:
- The application must set the
feePayerto the public key of the first signature. - The application must set the
recentBlockhashto the latest blockhash. - The application must serialize and deserialize the transaction before signing it. This ensures consistent ordering of the account keys, as a workaround for this issue.
- The wallet must not set the
feePayerandrecentBlockhash. - The wallet must verify the signatures, and if any are invalid, the wallet must reject the transaction as malformed.
account in the request, and
must do so only if a signature for the account in the request is expected.
If any signature except a signature for the account in the request is
expected, the wallet must reject the transaction as malicious.
Optional Message Field
The application may also include an optionalmessage field in the response
body:
<message> value must be a UTF-8 string that describes the nature of the
transaction response.
For example, this might be the name of an item being purchased, a discount
applied to the purchase, or a thank you note. The wallet should display the
value to the user.
The wallet and application should allow additional fields in the request body
and response body, which may be added by future specification.
Examples
URL describing a transaction request
URL describing a transaction request with query parameters
GET Request Example
GET Response Example
POST Request Example
POST Response Example
Extensions
Additional formats and fields may be incorporated into this specification to enable new use cases while ensuring compatibility with apps and wallets. Please open a Github issue to propose changes to the specification in order to solicit feedback from application and wallet developers. An actual example of such a proposal.See Also
- Solana Pay Specification v1.1 - Latest version with improvements
- Quick Start Guide - Implementation guides
- GitHub Repository - Reference implementations