@faremeter/payment-solana

中文文档
0.22.0发布于 2026/05/27LGPL-3.0-onlyTypeScriptESM + CJS近 30 天下载 2420

Solana payment scheme implementations for x402 protocol (SPL token transfers)

原始使用文档
文档目录12 节
  1. Installation
  2. Features
  3. API Reference
  4. Functions
  5. isAccountNotFoundError
  6. getTokenBalance
  7. Constants
  8. TOKEN_2022_PROGRAM_ADDRESS
  9. Interfaces
  10. GetTokenBalanceArgs
  11. Related Packages
  12. License

@faremeter/payment-solana

Solana payment scheme implementations for the x402 protocol, supporting SPL token transfers.

Installation

pnpm install @faremeter/payment-solana

Features

  • SPL token payments (USDC, etc.)
  • Devnet, testnet, and mainnet support
  • Automatic fee payer handling
  • Transaction verification
  • Works with any SPL token

API Reference

Functions

isAccountNotFoundError

Checks if an error indicates a token account was not found.

This handles various error formats from Solana RPC responses, including TokenAccountNotFoundError and AccountNotFoundError names, as well as message-based detection.

FunctionType
isAccountNotFoundError(e: unknown) => boolean

Parameters:

  • e: - The error to check

Returns:

True if the error indicates the account does not exist

getTokenBalance

Retrieves the SPL token balance for an account.

Looks up the associated token account (ATA) for the given wallet and mint, then fetches the token balance. Returns null if the account does not exist.

FunctionType
getTokenBalance(args: GetTokenBalanceArgs) => Promise<{ amount: bigint; decimals: any; } or null>

Parameters:

  • args: - The asset, account, and RPC client

Returns:

The balance amount and decimals, or null if the account does not exist

Constants

TOKEN_2022_PROGRAM_ADDRESS

ConstantType
TOKEN_2022_PROGRAM_ADDRESSAddress<"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb">

Interfaces

GetTokenBalanceArgs

Arguments for retrieving an SPL token balance.

PropertyTypeDescription
assetBase58AddressThe SPL token mint address
accountBase58AddressThe wallet address to check the balance for
rpcClientRpc<GetTokenAccountBalanceApi>Solana RPC client with token balance API support
tokenProgramAddress or undefinedThe token program address (defaults to TOKEN_PROGRAM_ADDRESS)

License

LGPL-3.0-only

版本与发布记录

@faremeter/payment-solana 共发布 23 个版本,首次发布于 2025/09/19;过去 12 个月发布了 12 个版本。

版本发布日期距今
0.22.0latest2026/05/275 个月前
0.21.02026/04/216 个月前
0.20.12026/04/147 个月前
0.20.02026/04/147 个月前
0.19.02026/03/217 个月前
0.18.02026/03/207 个月前

关于 @faremeter/payment-solana 的常见问题

@faremeter/payment-solana 是什么?

Solana payment scheme implementations for x402 protocol (SPL token transfers)

如何安装 @faremeter/payment-solana?

在项目目录运行 npm install @faremeter/payment-solana,或使用 pnpm add / yarn add / bun add。

@faremeter/payment-solana 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@faremeter/payment-solana 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@faremeter/payment-solana 可以商用吗?

@faremeter/payment-solana 使用 LGPL-3.0-only 许可。弱 Copyleft:作为库被调用时通常不要求开源你自己的代码,但修改库本身需以 LGPL 开源;前端打包合并后的适用边界存在不同理解。以上为概括,不构成法律意见,请以许可原文为准。

@faremeter/payment-solana 的下载量有多少?

根据 npm 官方下载统计,@faremeter/payment-solana 在 2026/10/15 – 2026/11/13 这 30 天内被下载 2,420 次,日均约 81 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@faremeter/payment-solana 还在维护吗?

最新版本 0.22.0 发布于 2026/05/27(5 个月前);至今共发布 23 个版本,其中过去 12 个月发布了 12 个;首次发布于 2025/09/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。