UNPKG

@solana/pay

Version:

`@solana/pay` is a JavaScript library for facilitating commerce on Solana by using a token transfer URL scheme. The URL scheme ensures that no matter the wallet or service used, the payment request must be created and interpreted in one standard way.

36 lines • 2.36 kB
import type { Address, GetSignaturesForAddressApi, GetTransactionApi, Instruction, Signature } from '@solana/kit'; import type { ClientWithRpc, ClientWithRpcSubscriptions } from '@solana/plugin-interfaces'; import type { LogsNotificationsApi } from '@solana/rpc-subscriptions-api'; import { createQROptions } from '../createQR.js'; import type { TransactionRequestURLFields, TransferRequestURLFields } from '../encodeURL.js'; import type { ConfirmedSignatureInfo, FindReferenceOptions } from '../findReference.js'; import type { Finality, Reference, TransferFields } from '../types.js'; import { validateTransfer } from '../validateTransfer.js'; import type { WatchReferenceOptions, WatchReferenceResult } from '../watchReference.js'; type MerchantRpcApi = GetSignaturesForAddressApi & GetTransactionApi; type MerchantRpcSubscriptionsApi = LogsNotificationsApi; type MerchantCompatibleClient = ClientWithRpc<MerchantRpcApi> & ClientWithRpcSubscriptions<MerchantRpcSubscriptionsApi>; /** Methods added to a client by the merchant plugin. */ export interface SolanaPayMerchantMethods { readonly pay: { encodeURL(fields: TransactionRequestURLFields | TransferRequestURLFields): URL; createQR(url: URL | string, size?: number, background?: string, color?: string): any; createQROptions(url: URL | string, size?: number, background?: string, color?: string): ReturnType<typeof createQROptions>; findReference(reference: Reference, options?: FindReferenceOptions): Promise<ConfirmedSignatureInfo>; watchReference(reference: Reference, options?: WatchReferenceOptions): Promise<WatchReferenceResult>; validateTransfer(signature: Signature, fields: TransferFields, options?: { commitment?: Finality; }): Promise<Awaited<ReturnType<typeof validateTransfer>>>; buildTransaction(feePayer: Address, instructions: Instruction[]): string; }; } /** * Merchant plugin for Solana Pay. * * Adds a `pay` namespace with merchant-side methods: URL encoding, * QR code generation, reference lookup, and transfer validation. * No payer/signer required — merchant only reads from the network. */ export declare function solanaPayMerchant(): <TClient extends MerchantCompatibleClient>(client: TClient) => SolanaPayMerchantMethods & TClient; export {}; //# sourceMappingURL=merchant.d.ts.map