### Install Dependencies and Start Development Server Source: https://github.com/solana-foundation/pay/blob/main/pdb/README.md Commands to install project dependencies and start the Express backend and Vite frontend development servers. ```bash pnpm install pnpm dev # starts Express (port 3000) + Vite (port 5173) ``` -------------------------------- ### Install Dependencies for Point of Sale App Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/examples/point-of-sale/README.md Navigate to the point of sale example directory and install project dependencies using npm. ```shell cd solana-pay/examples/point-of-sale npm install ``` -------------------------------- ### Setup Local Surfpool and Server Source: https://github.com/solana-foundation/pay/blob/main/rust/example/README.md Instructions for setting up a local Surfpool instance and configuring the example server to connect to it. This is an alternative to using the public sandbox. ```bash # Install and start Surfpool curl -sL https://run.surfpool.run/ | bash surfpool start # Point the server at localhost RPC_URL=http://localhost:8899 pnpm dev ``` -------------------------------- ### Install Dependencies Source: https://github.com/solana-foundation/pay/blob/main/CONTRIBUTING.md Run this command to install all project dependencies. Ensure Just, Rust, Solana CLI, and Node.js with pnpm are installed. ```shell just install ``` -------------------------------- ### Quick Start: Generate Keypair and Make Paid API Call Source: https://github.com/solana-foundation/pay/blob/main/README.md A quick start guide to generate a keypair (with biometric protection on macOS) and then make a paid API call using the '--sandbox' flag for an ephemeral funded keypair. ```sh # 1. Generate a keypair (Touch ID protected on macOS) pay setup # 2. Make a paid API call (--sandbox uses an ephemeral funded keypair) pay --sandbox curl https://payment-debugger.vercel.app/mpp/quote/AAPL # 3. Or let your AI agent handle it pay --sandbox claude ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/docs/README.md Run this command to install all necessary project dependencies. ```bash $ npm install ``` -------------------------------- ### Cloud Run Pay Server Start Command Source: https://github.com/solana-foundation/pay/blob/main/skills/pay/references/monetize-api.md Example command to start the Pay server on Cloud Run, specifying the provider spec, bind address, OpenAPI spec path, and OTLP sidecar. ```sh pay server start /app/providers/google/bigquery.yml \ --bind 0.0.0.0:8080 \ --openapi /app/providers/google/bigquery.json \ --otlp-sidecar 127.0.0.1:4318 ``` -------------------------------- ### GET Response Example Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/spec/SPEC.md Example of a successful GET request response, including label and icon. ```APIDOC ## GET Response ### Success Response (200) - **label** (string) - The label for the payment. - **icon** (string) - The URL of the icon for the payment. ### Response Example ```json { "label":"Michael Vines", "icon":"https://example.com/icon.svg" } ``` ``` -------------------------------- ### Install Pay from Source Source: https://github.com/solana-foundation/pay/blob/main/README.md Clone the 'pay' repository and use the provided 'just' commands to install the tool from its source code. ```sh git clone https://github.com/solana-foundation/pay.git cd pay just install pay ``` -------------------------------- ### Install and Run Server Dependencies Source: https://github.com/solana-foundation/pay/blob/main/rust/example/README.md Installs project dependencies and provides commands to run the server in watch mode or a single run. Assumes Node.js 20+ is installed. ```bash pnpm install pnpm dev # watch mode — restarts on file changes pnpm start # single run ``` -------------------------------- ### Start Local Development Server Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/examples/point-of-sale/README.md Run this command to start the local development server for the point of sale app. ```shell npm run dev ``` -------------------------------- ### Install @solana/pay and @solana/kit Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/core/README.md Install the necessary packages for Solana Pay and its core dependencies. ```bash npm install @solana/pay @solana/kit ``` -------------------------------- ### Solana Pay GET Response Example Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/docs/src/SPEC.md Shows a successful HTTP 200 OK response for a GET request, containing label and icon information. ```http HTTP/1.1 200 OK Connection: close Content-Type: application/json Content-Length: 62 Content-Encoding: gzip {"label":"Michael Vines","icon":"https://example.com/icon.svg"} ``` -------------------------------- ### Install @solana/pay Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/docs/src/core/OVERVIEW.md Install the Solana Pay library using pnpm. ```shell pnpm add @solana/pay ``` -------------------------------- ### Verify Pay Installation Source: https://github.com/solana-foundation/pay/blob/main/README.md Check the installed version of the 'pay' CLI tool to confirm a successful installation. ```sh pay --version ``` -------------------------------- ### API Request Handler Setup Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/docs/src/core/transaction-request/MERCHANT_INTEGRATION.md Set up the main API handler to manage incoming requests, directing GET and POST requests to their respective functions. This ensures only supported HTTP methods are processed. ```javascript const index = async (request, response) => { // We set up our handler to only respond to `GET` and `POST` requests. if (request.method === 'GET') return get(request, response); if (request.method === 'POST') return post(request, response); throw new Error(`Unexpected method ${request.method}`); }; ``` -------------------------------- ### Install Pay using Homebrew Source: https://github.com/solana-foundation/pay/blob/main/README.md Install the 'pay' CLI tool using the Homebrew package manager on macOS. ```sh brew install pay ``` -------------------------------- ### Solana Pay GET Request Example Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/docs/src/SPEC.md Illustrates the structure of a GET request to the Solana Pay endpoint, including order identification. ```http GET /solana-pay?order=12345 HTTP/1.1 Host: example.com Connection: close Accept: application/json Accept-Encoding: br, gzip, deflate ``` -------------------------------- ### Start Local Development Server Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/docs/README.md This command starts a local development server and automatically opens the website in your browser. Changes are typically reflected live without requiring a server restart. ```bash $ npm start ``` -------------------------------- ### Combined Client Setup and Usage Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/core/README.md Use `createSolanaPayClient` to initialize a client that provides both merchant and wallet functionalities. ```typescript import { createSolanaPayClient } from '@solana/pay'; const client = createSolanaPayClient({ rpcUrl: 'https://api.devnet.solana.com', payer: myWalletSigner, }); const url = client.pay.encodeURL({ recipient, amount: 1 }); const instructions = await client.pay.createTransfer({ recipient, amount: 1 }); await client.sendTransaction(instructions); ``` -------------------------------- ### Initialize Keypair with Pay Setup Source: https://context7.com/solana-foundation/pay/llms.txt Initializes a keypair stored in the OS-native credential store. Supports interactive setup, forcing re-creation, specifying backends like Apple Keychain or 1Password, and file-based keypairs for CI. Use `pay --version` and `pay account list` to verify after setup. ```sh pay setup ``` ```sh pay setup --force --backend AppleKeychain ``` ```sh pay setup --backend OnePassword --vault "Personal" ``` ```sh pay setup --backend File ``` ```sh pay --version pay account list ``` -------------------------------- ### POST Request Example Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/spec/SPEC.md Example of a POST request to the Solana Pay endpoint, including query parameters and request body. ```APIDOC ## POST Request ### Method POST ### Endpoint /solana-pay?order=12345 ### Request Body - **account** (string) - The account to send the payment to. ### Request Example ```json { "account":"mvines9iiHiQTysrwkJjGf2gb9Ex9jXJX8ns3qwf2kN" } ``` ``` -------------------------------- ### Wallet Client Setup and Usage Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/core/README.md Initialize a wallet client to parse payment URLs, create transfers, and send transactions. This client includes a transaction planner and executor. ```typescript import { createWalletClient } from '@solana/pay'; const wallet = createWalletClient({ rpcUrl: 'https://api.devnet.solana.com', payer: myWalletSigner, }); // Parse a Solana Pay URL and send the payment const parsed = wallet.pay.parseURL(url); const instructions = await wallet.pay.createTransfer({ recipient: parsed.recipient, amount: parsed.amount, }); await wallet.sendTransaction(instructions); ``` -------------------------------- ### POST Response Example Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/spec/SPEC.md Example of a successful POST request response, including a message and transaction details. ```APIDOC ## POST Response ### Success Response (200) - **message** (string) - A confirmation message. - **transaction** (string) - The transaction details. ### Response Example ```json { "message":"Thanks for all the fish", "transaction":"AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAECC4JMKqNplIXybGb/GhK1ofdVWeuEjXnQor7gi0Y2hMcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQECAAAMAgAAAAAAAAAAAAAA" } ``` ``` -------------------------------- ### Start MCP Server Source: https://context7.com/solana-foundation/pay/llms.txt Starts the MCP server on stdio, used by AI agents or other MCP-compatible hosts. Configuration can be done via command-line arguments or a JSON configuration file, specifying command, arguments, and environment variables. ```sh pay mcp ``` ```json { "mcpServers": { "pay": { "command": "/usr/local/bin/pay", "args": ["mcp"], "env": { "PAY_ACTIVE_ACCOUNT": "myaccount", "PAY_NETWORK_ENFORCED": "mainnet" } } } } ``` -------------------------------- ### Start Pay Server with OpenAPI Spec Source: https://github.com/solana-foundation/pay/blob/main/skills/pay/references/monetize-api.md Starts the Pay server using a provided YAML configuration and an OpenAPI JSON document. The gateway will serve a filtered and URL-rewritten version of the OpenAPI spec. ```sh pay server start provider.yml --openapi openapi.json ``` -------------------------------- ### Production Pay Server Configuration Source: https://github.com/solana-foundation/pay/blob/main/skills/pay/references/monetize-api.md Example YAML fragment for configuring the Pay server in a production environment. Ensure sensitive values are injected as environment variables. ```yaml operator: currencies: usd: ["USDC", "USDT", "CASH"] network: mainnet fee_payer: true rpc_url: "${PAY_RPC_URL}" recipient: "${PAY_PAYMENT_RECIPIENT}" signer: backend: gcp-kms key_name: "${PAY_GCP_KMS_KEY_NAME}" pubkey: "${PAY_GCP_KMS_PUBKEY}" ``` -------------------------------- ### Start Payment Gateway Server Source: https://context7.com/solana-foundation/pay/llms.txt Starts a payment gateway proxy from a YAML specification. Supports custom bind addresses, recipients, RPC URLs, and OpenAPI spec generation. The `--debugger` flag enables an embedded Payment Debugger UI. ```sh pay server start spec.yml ``` ```sh pay server start spec.yml --bind 0.0.0.0:8080 --recipient ``` ```sh pay server start --debugger spec.yml ``` ```sh pay server start spec.yml --rpc-url https://api.mainnet-beta.solana.com ``` ```sh pay server start spec.yml --openapi openapi.json --public-url https://api.example.com ``` ```sh pay server demo ``` ```sh pay server scaffold --name my-api --path ./my-api ``` -------------------------------- ### Run Local Pay Command Source: https://github.com/solana-foundation/pay/blob/main/rust/example/README.md Example command to interact with the local 'pay' service when running a local Surfpool instance. It demonstrates querying for a quote. ```bash pay --local curl http://localhost:3402/mpp/quote/SOL ``` -------------------------------- ### Merchant Client Setup and Usage Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/core/README.md Initialize a merchant client to encode payment URLs, generate QR codes, and find/validate transactions. No signer is required for these operations. ```typescript import { address } from '@solana/kit'; import { createMerchantClient } from '@solana/pay'; const merchant = createMerchantClient({ rpcUrl: 'https://api.devnet.solana.com', }); const recipient = address('MERCHANT_WALLET_ADDRESS'); const reference = address('UNIQUE_REFERENCE_ADDRESS'); // Encode a payment URL and show as QR code const url = merchant.pay.encodeURL({ recipient, amount: 1, reference }); const qr = merchant.pay.createQR(url); // After customer pays, find and validate the transaction const found = await merchant.pay.findReference(reference); await merchant.pay.validateTransfer(found.signature, { recipient, amount: 1, reference }); ``` -------------------------------- ### Clone Solana Pay Repository with Git Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/examples/point-of-sale/README.md Use this command to clone the Solana Pay repository if you have Git installed. ```shell git clone https://github.com/solana-labs/solana-pay.git ``` -------------------------------- ### Provider Markdown File Structure Source: https://github.com/solana-foundation/pay/blob/main/skills/pay/references/monetize-api.md Example file paths for defining provider configurations in the pay-skills repository. Use a three-level path when the gateway proxies another provider. ```text providers//.md providers///.md ``` -------------------------------- ### Query MPP Endpoint for Weather Source: https://github.com/solana-foundation/pay/blob/main/rust/example/README.md Example command to query an MPP endpoint for weather data using the 'pay' tool. This uses the sandbox environment. ```bash pay --sandbox curl http://localhost:3402/mpp/weather/paris ``` -------------------------------- ### Manage TypeScript SDK Source: https://github.com/solana-foundation/pay/blob/main/CONTRIBUTING.md Commands for managing the TypeScript SDK, including installing dependencies, building, linting, formatting, type checking, and running tests. ```shell just ts install # Install pnpm dependencies ``` ```shell just ts build # Build the core package ``` ```shell just ts lint # Check lint + formatting ``` ```shell just ts fmt # Auto-fix formatting + lint ``` ```shell just ts typecheck # Typecheck ``` ```shell just ts test # Run tests ``` ```shell just ts test-watch # Run tests in watch mode ``` -------------------------------- ### Query x402 Endpoint for Joke Source: https://github.com/solana-foundation/pay/blob/main/rust/example/README.md Example command to query an x402 (Payment Required) endpoint for a joke using the 'pay' tool. This uses the sandbox environment. ```bash pay --sandbox curl http://localhost:3402/x402/joke ``` -------------------------------- ### Clone Solana Pay Repository with GitHub CLI Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/examples/point-of-sale/README.md Use this command to clone the Solana Pay repository if you have the GitHub CLI installed. ```shell gh repo clone solana-labs/solana-pay ``` -------------------------------- ### Solana Pay POST Request Example Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/docs/src/SPEC.md Demonstrates a POST request to Solana Pay, including the order ID and the user's account information in JSON format. ```http POST /solana-pay?order=12345 HTTP/1.1 Host: example.com Connection: close Accept: application/json Accept-Encoding: br, gzip, deflate Content-Type: application/json Content-Length: 57 {"account":"mvines9iiHiQTysrwkJjGf2gb9Ex9jXJX8ns3qwf2kN"} ``` -------------------------------- ### Run Local SSL Proxy Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/examples/point-of-sale/README.md In a separate terminal, run this command to start a local SSL proxy, which may be required for the app to function correctly. ```shell npm run proxy ``` -------------------------------- ### Configure API Splits and Metering Source: https://github.com/solana-foundation/pay/blob/main/skills/pay/references/monetize-api.md Set up API endpoints with specific metering dimensions and revenue splits. This example defines a partner recipient and distributes 20% of the revenue for the 'v1/report' endpoint to them. ```yaml recipients: partner: account: "${PARTNER_WALLET}" label: "Partner" endpoints: - method: POST path: "v1/report" metering: dimensions: - direction: usage unit: requests scale: 1 tiers: - price_usd: 0.10 splits: - recipient: partner percent: 20 memo: "Partner revenue share" ``` -------------------------------- ### Run Debugger Inside Server Source: https://github.com/solana-foundation/pay/blob/main/skills/pay/references/monetize-api.md Alternative method to start the Pay server with the debugger integrated. This allows debugging directly within the server process. ```sh pay --sandbox server start provider.yml --debugger ``` -------------------------------- ### Query x402 Endpoint for Fact Source: https://github.com/solana-foundation/pay/blob/main/rust/example/README.md Example command to query an x402 (Payment Required) endpoint for a fact using the 'pay' tool. This uses the sandbox environment. ```bash pay --sandbox curl http://localhost:3402/x402/fact ``` -------------------------------- ### Query MPP Endpoint for Quote Source: https://github.com/solana-foundation/pay/blob/main/rust/example/README.md Example command to query an MPP (Multi-Party Payment) endpoint for a quote using the 'pay' tool. This uses the sandbox environment. ```bash pay --sandbox curl http://localhost:3402/mpp/quote/AAPL ``` -------------------------------- ### Sign-message GET Request Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/spec/message-signing-spec.md Example of a GET request to the sign-message endpoint, used for retrieving information or initiating a signing process. ```APIDOC ## GET /solana-pay/sign-message ### Description Initiates a message signing request or retrieves information related to message signing. ### Method GET ### Endpoint /solana-pay/sign-message ### Query Parameters - **id** (string) - Optional - An identifier for the request. ### Request Example ```http GET /solana-pay/sign-message?id=678910 HTTP/1.1 Host: example.com Connection: close Accept: application/json Accept-Encoding: br, gzip, deflate ``` ### Response #### Success Response (200) - **label** (string) - The label associated with the request. - **icon** (string) - The URL of an icon representing the request. #### Response Example ```json { "label": "Michael Vines", "icon": "https://example.com/icon.svg" } ``` ``` -------------------------------- ### Run Bundled Solana Pay Demo Source: https://context7.com/solana-foundation/pay/llms.txt Execute the bundled demo for Solana Pay with sample payment endpoints. ```bash pay server demo ``` -------------------------------- ### Build and Test Pay from Source Source: https://github.com/solana-foundation/pay/blob/main/README.md Commands to build the release binary, run all tests, and perform linting using 'clippy' for the 'pay' project when building from source. ```sh cd rust just build # release binary just test # all tests just lint # clippy (warnings = errors) ``` -------------------------------- ### Create Wallet Client and Process Payment Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/docs/src/core/OVERVIEW.md Initialize a wallet client with a signer and use it to parse a payment URL, create transfer instructions, and send the transaction. ```typescript import { createWalletClient } from '@solana/pay'; const wallet = createWalletClient({ rpcUrl: 'https://api.mainnet-beta.solana.com', payer: walletSigner, }); const parsed = wallet.pay.parseURL(url); const instructions = await wallet.pay.createTransfer({ recipient, amount }); await wallet.sendTransaction(instructions); ``` -------------------------------- ### Solana Pay CLI Basic Commands Source: https://github.com/solana-foundation/pay/blob/main/skills/pay/references/setup-cli.md A list of common Solana Pay CLI commands for setup, launching agents, making authorized HTTP requests, and managing skills and accounts. Use the `--sandbox` flag for ephemeral devnet wallets. ```sh pay setup # create a wallet ``` ```sh pay claude # launch Claude Code with pay ``` ```sh pay codex # launch Codex with pay ``` ```sh pay curl # HTTP request with user-authorized 402 handling ``` ```sh pay --sandbox curl # use an ephemeral devnet wallet ``` ```sh pay skills list # browse the API registry ``` ```sh pay skills endpoints # list provider endpoints ``` ```sh pay account list # list accounts ``` ```sh pay topup # fund account ``` ```sh pay server start # run a payment gateway for your API ``` -------------------------------- ### GET Response JSON Structure Source: https://github.com/solana-foundation/pay/blob/main/typescript/packages/solana-pay/docs/src/SPEC.md The expected JSON structure for a GET response from an application to a wallet, containing a label and an icon URL. ```json {"label":"