Documentation Index
Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
Helius TypeScript SDK为所有Helius API提供类型安全的方法,使代理与Solana进行交互的速度最快。
- Package:
helius-sdk (npm / pnpm / yarn)
- Version: 2.x (使用
@solana/kit,而不是 @solana/web3.js)
- Runtime: 任何JavaScript运行时 — 浏览器、Deno、Bun、edge runtimes(Cloudflare Workers, Vercel Edge), Node.js 20+
- TypeScript: 5.8+ (包含完整类型定义)
- License: ISC
快速开始
import { createHelius } from "helius-sdk";
const helius = createHelius({
apiKey: "YOUR_API_KEY",
network: "mainnet", // or "devnet"
});
// Get all NFTs and tokens owned by a wallet
const assets = await helius.getAssetsByOwner({
ownerAddress: "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY",
page: 1,
limit: 50,
});
// Get transaction history (with token account activity)
const txs = await helius.getTransactionsForAddress([
"86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY",
{ limit: 100, transactionDetails: "full", filters: { tokenAccounts: "balanceChanged" } },
]);
// Send a transaction via Helius Sender (ultra-low latency)
const sig = await helius.tx.sendTransactionWithSender({
instructions: [transferInstruction],
signers: [walletSigner],
region: "US_EAST",
});
客户端选项
const helius = createHelius({
apiKey: "YOUR_API_KEY", // Required for webhooks, enhanced txs, wallet API
network: "mainnet", // "mainnet" (default) or "devnet"
baseUrl: "https://custom..", // Override RPC URL (optional)
rebateAddress: "wallet", // Wallet for RPC rebates (optional)
userAgent: "my-agent/1.0", // Sent as X-Helius-Client header (optional)
});
命名空间
所有方法通过helius客户端访问。DAS API 方法和标准Solana RPC 方法可直接在helius.*上使用。其他功能组织为命名空间:
| Namespace | 访问 | 目的 |
|---|
| DAS API | helius.getAsset(), helius.getAssetsByOwner(), 等 | 查询NFTs、代币、压缩资产 |
| RPC V2 | helius.getTransactionsForAddress(), helius.getProgramAccountsV2() | 增强的RPC,支持分页和过滤 |
| Transactions | helius.tx.* | 智能交易和Helius Sender |
| Enhanced | helius.enhanced.* | 将交易解析成人类可读格式 |
| Webhooks | helius.webhooks.* | 创建和管理webhook订阅 |
| WebSockets | helius.ws.* | 实时区块链数据流 |
| Staking | helius.stake.* | 将SOL质押到Helius验证者 |
| ZK Compression | helius.zk.* | 压缩账户和证明 |
| Wallet API | helius.wallet.* | 余额、历史、身份查找 |
| Standard RPC | helius.getBalance(), helius.getSlot(), 等 | 通过代理实现所有标准Solana RPC方法 |
| Raw RPC | helius.raw | 直接访问底层@solana/kit Rpc客户端 |
| Auth | import { makeAuthClient } from "helius-sdk/auth/client" | 代理注册和API密钥管理(独立导入) |
编程注册(认证模块)
认证模块是一个独立的导入——不是在主HeliusClient上。用于编程代理注册流程。
import { makeAuthClient } from "helius-sdk/auth/client";
const auth = makeAuthClient();
// Hosted-link signup (returns a paymentUrl the user opens in a browser):
const link = await auth.signup({
secretKey: keypair.secretKey,
plan: "agent",
email: "you@example.com",
firstName: "Ada",
lastName: "Lovelace",
});
// link: { kind: "payment_required", jwt, refId, walletAddress, paymentLink: { paymentUrl, ... } }
// Or pay USDC directly from the local keypair and provision in one call:
const result = await auth.signupAndPay({
secretKey: keypair.secretKey,
plan: "agent",
email: "you@example.com",
firstName: "Ada",
lastName: "Lovelace",
});
// result.kind: "completed" | "pending" | "expired" | "failed" | "already_subscribed" | "upgrade_required"
// On "completed": result has { jwt, walletAddress, projectId, apiKey, endpoints, txSignature }
深入探讨
SDK API 文档(TypeDoc)
从源代码生成的完整 API 文档
迁移指南(1.x 到 2.x)
从 @solana/web3.js 升级到 @solana/kit