> ## Documentation Index
> Fetch the complete documentation index at: https://solana.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Installation

> Install Solana Pay SDK and get started with payments

Get started with Solana Pay by installing the JavaScript SDK and setting up your
development environment. The SDK is framework-agnostic and works with any
JavaScript environment.

## System Requirements

- **Node.js**: Version 20.18 or higher, the floor `@solana/kit` declares
  (Node.js 20 or later also provides the Ed25519 `crypto.subtle` support)
- **Package manager**: npm, which ships with Node.js
- **TypeScript**: Version 5+ (recommended but not required)

## Install Solana Pay SDK

```bash
npm install @solana/pay@beta @solana/kit@^6.5.0
```

### Peer Dependencies

`@solana/pay` declares all of these packages as required peer dependencies. npm
7 and later installs them with `@solana/pay`:

| Package                               | Version  |
| ------------------------------------- | -------- |
| `@solana/kit`                         | `^6.5.0` |
| `@solana/keys`                        | `^6.5.0` |
| `@solana/rpc-subscriptions-api`       | `^6.5.0` |
| `@solana/rpc-subscriptions-spec`      | `^6.5.0` |
| `@solana-program/system`              | `^0.12`  |
| `@solana-program/token`               | `^0.12`  |
| `@solana-program/token-2022`          | `^0.9`   |
| `@solana-program/memo`                | `^0.11`  |
| `@solana/kit-plugin-rpc`              | `^0.8`   |
| `@solana/kit-plugin-payer`            | `^0.8`   |
| `@solana/kit-plugin-instruction-plan` | `^0.8`   |

### Packages Your Code Imports

Add the peers your own code imports to your `package.json`, so their versions
stay pinned. For transfer creation and validation (SOL and SPL token
transfers):

```bash
npm install @solana-program/system@^0.12 @solana-program/token@^0.12 @solana-program/token-2022@^0.9 @solana-program/memo@^0.11
```

For the client factories (`createMerchantClient`, `createWalletClient`), also
install the kit plugins:

```bash
npm install @solana/kit-plugin-rpc@^0.8 @solana/kit-plugin-payer@^0.8 @solana/kit-plugin-instruction-plan@^0.8
```

## Use ES Modules

Many examples in these guides use top-level `await`, which only works in an ES
module. In a default `npm init` project (`"type": "commonjs"`),
`npx tsx file.ts` fails with `Top-level await is currently not supported with
the "cjs" output format`. Set the package type to `module`, or name your files
with the `.mts` extension:

```bash
npm pkg set type=module
```

## TypeScript Configuration

If using TypeScript, ensure your `tsconfig.json` includes:

```json
{
  "compilerOptions": {
    "module": "ESNext",
    "target": "ES2022",
    "lib": ["ES2022", "DOM", "DOM.Iterable"],
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "skipLibCheck": true
  }
}
```

## Environment Setup

### Development Environment

Set up environment variables for development:

```bash
# .env.local
SOLANA_RPC_URL=https://api.devnet.solana.com
SOLANA_NETWORK=devnet
```

### Production Environment

For production, use mainnet endpoints:

```bash
# .env.production
SOLANA_RPC_URL=https://api.mainnet.solana.com
SOLANA_NETWORK=mainnet-beta
```

## Verify Installation

Create a simple test to verify everything is working:

```typescript
// test-installation.ts
import { address } from "@solana/kit";
import { encodeURL } from "@solana/pay";

// Test creating a payment URL
const recipient = address("FvJ8k8HhXp4a3zQyFMZd4FvEqcYdYE7gSZWxrEBRfBsB");

const url = encodeURL({
  recipient,
  amount: 0.01,
  label: "Test Store",
  message: "Test payment"
});

console.log("Solana Pay URL:", url.toString());
// Output: solana:FvJ8k8Hh...?amount=0.01&label=Test+Store&message=Test+payment
// (Spaces are form-encoded as "+"; parsers accept both "+" and "%20".)
```

Run the test:

```bash
npx tsx test-installation.ts
```

You should see a valid Solana Pay URL in the console.

## Common Issues and Solutions

### Module Resolution Errors

If you see errors like "Cannot resolve module '@solana/pay'":

1. Clear the npm cache:

   ```bash
   npm cache clean --force
   ```

2. Delete `node_modules` and reinstall:
   ```bash
   rm -rf node_modules
   npm install
   ```

### TypeScript Errors

If you encounter TypeScript errors:

1. Update to the latest TypeScript version (5+)
2. Ensure `moduleResolution` is set to `"bundler"` or `"nodenext"` in your
   `tsconfig.json`

## Next Steps

Now that you have Solana Pay installed, choose your integration path:

- **[Transfer Requests](/developers/docs/tools/solana-pay/quickstart/transfer-requests)** -
  Simple payment URLs for basic transfers
- **[Transaction Requests](/developers/docs/tools/solana-pay/quickstart/transaction-requests)** -
  Interactive payment flows
- **[QR Code Integration](/developers/docs/tools/solana-pay/quickstart/qr-codes)** -
  Generate QR codes for mobile payments

## Development Tools

Consider installing these helpful development tools:

```bash
# Solana CLI (for testing and key generation)
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"

# Local validator for testing
solana-test-validator
```

## Resources

- **[GitHub Repository](https://github.com/solana-foundation/pay)** - Source
  code and examples
- **[Solana Cookbook](/developers/cookbook)** - Solana development recipes
