Solana Pay

The Commerce Kit is currently in beta. APIs may change before the stable release. For additional details, see the Commerce Kit documentation.

Solana Pay is a standard protocol for encoding payment requests as URLs. These URLs can be shared as links, encoded as QR codes for mobile wallets, or used to build payment transactions programmatically.

The @solana-commerce/solana-pay package provides URL encoding/parsing, QR code generation, and transaction building—compatible with @solana/kit.

Installation

pnpm add @solana-commerce/solana-pay

Creating Payment URLs

Use encodeURL to create a solana: protocol URL that wallets can parse:

import { encodeURL } from "@solana-commerce/solana-pay";
const url = encodeURL({
recipient: address("merchant-wallet-address"),
amount: 100000000n, // 0.1 SOL in lamports
label: "Coffee Shop",
message: "Thanks for your order!"
});
console.log(url.toString());
// solana:merchant...?amount=0.1&label=Coffee%20Shop&message=...

URL Parameters

ParameterTypeDescription
recipientAddressMerchant wallet address (required)
amountbigintAmount in lamports or token minor units
splTokenAddressSPL token mint address (omit for SOL)
referenceAddress[]Unique reference(s) for tracking payments
labelstringMerchant name shown in wallet
messagestringMessage shown before payment
memostringOn-chain memo attached to transaction

SPL Token Payments

For stablecoin payments, specify the token mint:

import { encodeURL } from "@solana-commerce/solana-pay";
const url = encodeURL({
recipient: address("merchant-wallet"),
amount: 25000000n, // 25 USDC (6 decimals)
splToken: USDC_MINT,
label: "My Store"
});

Payment Tracking with References

Generate a unique reference to identify specific payments:

import { encodeURL } from "@solana-commerce/solana-pay";
import { address, generateKeyPairSigner } from "@solana/kit";
const orderReference = (await generateKeyPairSigner()).address;
const url = encodeURL({
recipient: address(MERCHANT_WALLET_ADDRESS),
amount: 500000000n, // 0.5 SOL
reference: orderReference,
memo: `Order-${Date.now()}`
});
// Query the blockchain later for transactions containing this reference

Generating QR Codes

Use createQR to generate scannable QR codes for mobile wallets:

import { createQR, encodeURL } from "@solana-commerce/solana-pay";
import { address } from "@solana/kit";
const url = encodeURL({
recipient: address(MERCHANT_WALLET_ADDRESS),
amount: 100000000n,
label: "Coffee Shop"
});
const qrCode = await createQR(
url.toString(),
400, // size in pixels
"white", // background
"black" // foreground
);
// Use as image source
document.getElementById("qr").src = qrCode;

Styled QR Codes

For branded QR codes with logos and custom styling:

import { createStyledQRCode, encodeURL } from "@solana-commerce/solana-pay";
const qr = await createStyledQRCode(url.toString(), {
width: 600,
margin: 3,
color: {
dark: "#9945FF", // Solana purple
light: "#FFFFFF"
},
errorCorrectionLevel: "H",
dotStyle: "dots",
cornerStyle: "extra-rounded",
logo: "/your-logo.png",
logoSize: 120
});

Building Transactions

Use createTransfer to build a complete transaction for signing:

import { createTransfer } from "@solana-commerce/solana-pay";
const transaction = await createTransfer(
client.rpc,
address(SENDER_WALLET_ADDRESS),
{
recipient: address(MERCHANT_WALLET_ADDRESS),
amount: 100000000n, // 0.1 SOL
memo: "Coffee purchase"
}
);

For SPL tokens, include the mint address:

const USDC_MINT = address("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v");
const transaction = await createTransfer(
client.rpc,
address(SENDER_WALLET_ADDRESS),
{
recipient: address(MERCHANT_WALLET_ADDRESS),
amount: 25000000n, // 25 USDC
splToken: USDC_MINT,
reference: [orderReference],
memo: "Order #12345"
}
);

Parsing URLs

Validate and extract data from Solana Pay URLs:

import { parseURL, ParseURLError } from "@solana-commerce/solana-pay";
try {
const parsed = parseURL("solana:merchant...?amount=1.5&label=Store");
console.log(parsed.recipient); // Address
console.log(parsed.amount); // 1500000000n (lamports)
console.log(parsed.label); // "Store"
} catch (error) {
if (error instanceof ParseURLError) {
console.error("Invalid URL:", error.message);
}
}

Is this page helpful?

Table of Contents

Edit Page

Managed by

© 2026 Solana Foundation.
All rights reserved.
Get connected