-
Notifications
You must be signed in to change notification settings - Fork 45
docs: add Solana as payment method #451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| --- | ||
| imageDescription: "One-time Solana payments using signed transactions or confirmed transaction signatures" | ||
| --- | ||
|
|
||
| import { Cards } from 'vocs' | ||
| import { SpecCard } from '../../../components/SpecCard' | ||
|
|
||
| # Solana charge [One-time payments on Solana] | ||
|
|
||
| The Solana implementation of the [charge](/intents/charge) intent. | ||
|
|
||
| The server issues a charge challenge describing the expected amount, currency, recipient, and Solana-specific `methodDetails`. The client either presents a signed transaction for server broadcast or presents a confirmed transaction signature. The server verifies the transfer on-chain and returns the resource with a receipt. | ||
|
|
||
| This method is best for fixed-price API calls, digital goods, and payments that should settle directly on Solana. | ||
|
|
||
| ## Server | ||
|
|
||
| Use `solana.charge` to gate endpoints behind native SOL or SPL token payments. | ||
|
|
||
| ```ts | ||
| import { Mppx } from 'mppx/server' | ||
| import { solana } from '@solana/mpp/server' | ||
|
|
||
| const mppx = Mppx.create({ | ||
| methods: [solana.charge({ | ||
| recipient: '9xAXssX9j7vuK99c7cFwqbixzL3bFrzPy9PUhCtDPAYJ', | ||
| network: 'devnet', | ||
| })], | ||
| secretKey: process.env.MPP_SECRET_KEY!, | ||
| }) | ||
| ``` | ||
|
|
||
| ## Client | ||
|
|
||
| Use `solana.charge` with `Mppx.create` to automatically handle Solana charge challenges. | ||
|
|
||
| ```ts | ||
| import { Mppx } from 'mppx/client' | ||
| import { solana } from '@solana/mpp/client' | ||
|
|
||
| const mppx = Mppx.create({ | ||
| methods: [solana.charge()], | ||
| }) | ||
| ``` | ||
|
|
||
| ## Solana-specific request fields | ||
|
|
||
| The Solana charge request extends the base charge schema with `methodDetails` fields such as: | ||
|
|
||
| - `network` | ||
| - `decimals` | ||
| - `tokenProgram` | ||
| - `feePayer` | ||
| - `feePayerKey` | ||
| - `splits` | ||
|
|
||
| These fields let the server describe whether payment is in SOL or an SPL asset, whether fee sponsorship is available, and whether the payment should be split across multiple recipients. | ||
|
|
||
| ## Specification | ||
|
|
||
| <Cards> | ||
| <SpecCard to="https://paymentauth.org/draft-solana-charge-00" /> | ||
| </Cards> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| --- | ||
| imageDescription: "Native SOL and SPL token payments on Solana for one-time and session-based billing" | ||
| --- | ||
|
|
||
| # Solana [Native SOL and SPL token payments] | ||
|
|
||
| The Solana payment method enables MPP payments on Solana using native SOL, SPL tokens, and Token-2022 assets. Solana supports two intents: **charge** for one-time payments and **session** for escrowed, pay-as-you-go billing. | ||
|
|
||
| The reference implementation is provided by [`@solana/mpp`](https://github.com/solana-foundation/mpp-sdk), which extends [`mppx`](https://github.com/tempoxyz/mpp) with Solana-native client and server handlers. | ||
|
|
||
| ## Installation | ||
|
|
||
| :::code-group | ||
| ```bash [npm] | ||
| npm install @solana/mpp mppx @solana/kit | ||
| ``` | ||
| ```bash [pnpm] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: can we add the |
||
| pnpm add @solana/mpp mppx @solana/kit | ||
| ``` | ||
| ::: | ||
|
|
||
| ## Why Solana | ||
|
|
||
| Solana enables several useful capabilities for MPP: | ||
|
|
||
| - **Split payouts and richer settlement flows** through multiple instructions per transaction | ||
| - **Fast finality** for low-latency charge flows | ||
| - **Cheap transactions** for micropayments and fee-sponsored UX | ||
| - **Native fee payer support** so servers can sponsor network fees | ||
| - **Token flexibility** across SOL, SPL, and Token-2022 assets | ||
| - **Delegated signer options** including Ed25519 and passkey-friendly secp256r1 flows | ||
|
|
||
| ## Choosing an intent | ||
|
|
||
| | | **Charge** | **Session** | | ||
| |---|---|---| | ||
| | **Pattern** | One-time payment per request | Escrow once, pay incrementally with vouchers | | ||
| | **Latency overhead** | One transaction or confirmed signature per request | Low after open; vouchers are off-chain | | ||
| | **Throughput** | Best for discrete purchases | Best for high-frequency metered usage | | ||
| | **Best for** | Paid API calls, downloads, fixed-price purchases | LLM APIs, streaming, repeated calls | | ||
| | **Settlement** | Immediate on-chain transfer | Escrow on-chain, settle accepted usage later | | ||
|
|
||
| ## Intents | ||
|
|
||
| <div className="vocs:grid vocs:grid-cols-1 vocs:md:grid-cols-2 vocs:gap-4"> | ||
| <a href="/payment-methods/solana/charge" className="vocs:relative vocs:flex vocs:flex-col vocs:space-y-2 vocs:rounded-md vocs:bg-surfaceTint/70 vocs:border vocs:border-primary vocs:p-4 vocs:no-underline vocs:transition-colors vocs:hover:bg-surfaceTint"> | ||
| <div className="vocs:size-8 vocs:flex vocs:items-center vocs:justify-center vocs:rounded-lg vocs:border vocs:border-primary vocs:bg-surface vocs:text-accent"> | ||
| <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 397.7 311.7" fill="currentColor"><path d="M64.3 237.9c2.4-2.4 5.7-3.8 9.1-3.8h317.6c5.7 0 8.5 6.9 4.5 10.9l-62.7 62.7c-2.4 2.4-5.7 3.8-9.1 3.8H6.1c-5.7 0-8.5-6.9-4.5-10.9l62.7-62.7ZM64.3 3.8C66.7 1.4 70 0 73.4 0H391c5.7 0 8.5 6.9 4.5 10.9l-62.7 62.7c-2.4 2.4-5.7 3.8-9.1 3.8H6.1c-5.7 0-8.5-6.9-4.5-10.9L64.3 3.8Zm268.5 116.2c-2.4-2.4-5.7-3.8-9.1-3.8H6.1c-5.7 0-8.5 6.9-4.5 10.9l62.7 62.7c2.4 2.4 5.7 3.8 9.1 3.8h317.6c5.7 0 8.5-6.9 4.5-10.9L332.8 120Z"/></svg> | ||
| </div> | ||
| <div className="vocs:text-[15px] vocs:font-medium vocs:text-heading">Solana charge</div> | ||
| <div className="vocs:text-sm vocs:leading-relaxed vocs:text-secondary">One-time payments with signed transactions or confirmed signatures</div> | ||
| </a> | ||
| <a href="https://github.com/tempoxyz/mpp-specs/pull/201" className="vocs:relative vocs:flex vocs:flex-col vocs:space-y-2 vocs:rounded-md vocs:bg-surfaceTint/70 vocs:border vocs:border-primary vocs:p-4 vocs:no-underline vocs:transition-colors vocs:hover:bg-surfaceTint"> | ||
| <div className="vocs:size-8 vocs:flex vocs:items-center vocs:justify-center vocs:rounded-lg vocs:border vocs:border-primary vocs:bg-surface vocs:text-accent"> | ||
| <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 397.7 311.7" fill="currentColor"><path d="M64.3 237.9c2.4-2.4 5.7-3.8 9.1-3.8h317.6c5.7 0 8.5 6.9 4.5 10.9l-62.7 62.7c-2.4 2.4-5.7 3.8-9.1 3.8H6.1c-5.7 0-8.5-6.9-4.5-10.9l62.7-62.7ZM64.3 3.8C66.7 1.4 70 0 73.4 0H391c5.7 0 8.5 6.9 4.5 10.9l-62.7 62.7c-2.4 2.4-5.7 3.8-9.1 3.8H6.1c-5.7 0-8.5-6.9-4.5-10.9L64.3 3.8Zm268.5 116.2c-2.4-2.4-5.7-3.8-9.1-3.8H6.1c-5.7 0-8.5 6.9-4.5 10.9l62.7 62.7c2.4 2.4 5.7 3.8 9.1 3.8h317.6c5.7 0 8.5-6.9 4.5-10.9L332.8 120Z"/></svg> | ||
| </div> | ||
| <div className="vocs:text-[15px] vocs:font-medium vocs:text-heading">Solana session</div> | ||
| <div className="vocs:text-sm vocs:leading-relaxed vocs:text-secondary">Coming soon: Solana sessions with off-chain vouchers and on-chain settlement</div> | ||
| </a> | ||
| </div> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍