helius
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHelius Development Guide
Helius 开发指南
Build high-performance Solana applications with Helius - the leading RPC and API infrastructure provider with 99.99% uptime, global edge nodes, and developer-first APIs.
借助Helius构建高性能Solana应用——这是一家拥有99.99%正常运行时间、全球边缘节点和开发者友好型API的领先RPC与API基础设施提供商。
Overview
概述
Helius provides:
- RPC Infrastructure: Globally distributed nodes with ultra-low latency
- DAS API: Unified NFT and token data (compressed & standard)
- Enhanced Transactions: Parsed, human-readable transaction data
- Priority Fee API: Real-time fee recommendations
- Webhooks: Event-driven blockchain monitoring
- ZK Compression: Compressed account and token APIs
- LaserStream: gRPC-based real-time data streaming
- Sender API: Optimized transaction landing
Helius提供以下服务:
- RPC基础设施:全球分布式节点,超低延迟
- DAS API:统一的NFT与代币数据(含压缩资产与标准资产)
- 增强型交易:已解析、易读的交易数据
- 优先费用API:实时费用建议
- Webhook:事件驱动的区块链监控
- ZK压缩:压缩账户与代币API
- LaserStream:基于gRPC的实时数据流
- Sender API:优化的交易落地
Quick Start
快速开始
Installation
安装
bash
undefinedbash
undefinedInstall Helius SDK
Install Helius SDK
npm install helius-sdk
npm install helius-sdk
Or with pnpm (recommended)
Or with pnpm (recommended)
pnpm add helius-sdk
undefinedpnpm add helius-sdk
undefinedGet Your API Key
获取API密钥
- Visit dashboard.helius.dev
- Create an account or sign in
- Generate an API key
- Store it securely (never commit to git)
- 访问 dashboard.helius.dev
- 创建账户或登录
- 生成API密钥
- 安全存储(切勿提交至git)
Environment Setup
环境配置
bash
undefinedbash
undefined.env file
.env file
HELIUS_API_KEY=your_api_key_here
undefinedHELIUS_API_KEY=your_api_key_here
undefinedBasic Setup
基础配置
typescript
import { createHelius } from "helius-sdk";
const helius = createHelius({
apiKey: process.env.HELIUS_API_KEY!,
});
// RPC endpoint URLs
const MAINNET_RPC = `https://mainnet.helius-rpc.com/?api-key=${process.env.HELIUS_API_KEY}`;
const DEVNET_RPC = `https://devnet.helius-rpc.com/?api-key=${process.env.HELIUS_API_KEY}`;typescript
import { createHelius } from "helius-sdk";
const helius = createHelius({
apiKey: process.env.HELIUS_API_KEY!,
});
// RPC endpoint URLs
const MAINNET_RPC = `https://mainnet.helius-rpc.com/?api-key=${process.env.HELIUS_API_KEY}`;
const DEVNET_RPC = `https://devnet.helius-rpc.com/?api-key=${process.env.HELIUS_API_KEY}`;RPC Infrastructure
RPC基础设施
Endpoints
端点
| Network | HTTP Endpoint | WebSocket Endpoint |
|---|---|---|
| Mainnet | | |
| Devnet | | |
| 网络 | HTTP端点 | WebSocket端点 |
|---|---|---|
| 主网 | | |
| 测试网 | | |
Using with @solana/kit
与@solana/kit配合使用
typescript
import { createSolanaRpc, createSolanaRpcSubscriptions } from "@solana/kit";
const rpc = createSolanaRpc(
`https://mainnet.helius-rpc.com/?api-key=${process.env.HELIUS_API_KEY}`
);
const rpcSubscriptions = createSolanaRpcSubscriptions(
`wss://mainnet.helius-rpc.com/?api-key=${process.env.HELIUS_API_KEY}`
);
// Make RPC calls
const slot = await rpc.getSlot().send();
const balance = await rpc.getBalance(address).send();typescript
import { createSolanaRpc, createSolanaRpcSubscriptions } from "@solana/kit";
const rpc = createSolanaRpc(
`https://mainnet.helius-rpc.com/?api-key=${process.env.HELIUS_API_KEY}`
);
const rpcSubscriptions = createSolanaRpcSubscriptions(
`wss://mainnet.helius-rpc.com/?api-key=${process.env.HELIUS_API_KEY}`
);
// Make RPC calls
const slot = await rpc.getSlot().send();
const balance = await rpc.getBalance(address).send();Helius-Exclusive RPC Methods
Helius专属RPC方法
| Method | Description |
|---|---|
| Cursor-based pagination for program accounts |
| Efficient token account retrieval |
| Advanced transaction history with filtering |
typescript
// getProgramAccountsV2 - handles large datasets efficiently
const accounts = await helius.rpc.getProgramAccountsV2({
programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
cursor: null, // Start from beginning
limit: 100,
});
// getTransactionsForAddress - advanced filtering
const transactions = await helius.rpc.getTransactionsForAddress({
address: "wallet_address",
before: null,
until: null,
limit: 100,
source: "JUPITER", // Filter by source
type: "SWAP", // Filter by type
});| 方法 | 描述 |
|---|---|
| 基于游标の程序账户分页查询 |
| 高效检索代币账户 |
| 带过滤功能の高级交易历史查询 |
typescript
// getProgramAccountsV2 - handles large datasets efficiently
const accounts = await helius.rpc.getProgramAccountsV2({
programAddress: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
cursor: null, // Start from beginning
limit: 100,
});
// getTransactionsForAddress - advanced filtering
const transactions = await helius.rpc.getTransactionsForAddress({
address: "wallet_address",
before: null,
until: null,
limit: 100,
source: "JUPITER", // Filter by source
type: "SWAP", // Filter by type
});DAS API (Digital Asset Standard)
DAS API(数字资产标准)
Unified access to NFTs, tokens, and compressed assets.
统一访问NFT、代币与压缩资产。
Core Methods
核心方法
typescript
// Get single asset
const asset = await helius.getAsset({
id: "asset_id_here",
});
// Get assets by owner
const assets = await helius.getAssetsByOwner({
ownerAddress: "wallet_address",
page: 1,
limit: 100,
displayOptions: {
showFungible: true,
showNativeBalance: true,
},
});
// Get assets by collection
const collection = await helius.getAssetsByGroup({
groupKey: "collection",
groupValue: "collection_address",
page: 1,
limit: 100,
});
// Search assets with filters
const results = await helius.searchAssets({
ownerAddress: "wallet_address",
tokenType: "fungible",
burnt: false,
page: 1,
limit: 50,
});
// Get batch of assets
const batch = await helius.getAssetBatch({
ids: ["asset1", "asset2", "asset3"],
});
// Get asset proof (for compressed NFTs)
const proof = await helius.getAssetProof({
id: "compressed_nft_id",
});typescript
// Get single asset
const asset = await helius.getAsset({
id: "asset_id_here",
});
// Get assets by owner
const assets = await helius.getAssetsByOwner({
ownerAddress: "wallet_address",
page: 1,
limit: 100,
displayOptions: {
showFungible: true,
showNativeBalance: true,
},
});
// Get assets by collection
const collection = await helius.getAssetsByGroup({
groupKey: "collection",
groupValue: "collection_address",
page: 1,
limit: 100,
});
// Search assets with filters
const results = await helius.searchAssets({
ownerAddress: "wallet_address",
tokenType: "fungible",
burnt: false,
page: 1,
limit: 50,
});
// Get batch of assets
const batch = await helius.getAssetBatch({
ids: ["asset1", "asset2", "asset3"],
});
// Get asset proof (for compressed NFTs)
const proof = await helius.getAssetProof({
id: "compressed_nft_id",
});DAS Method Reference
DAS方法参考
| Method | Description |
|---|---|
| Get single asset by ID |
| Get multiple assets |
| Get merkle proof for cNFT |
| Get multiple proofs |
| All assets for wallet |
| Assets by creator address |
| Assets by authority |
| Assets by collection/group |
| Advanced search with filters |
| Get NFT edition info |
| Get token accounts |
| Transaction history for asset |
| 方法 | 描述 |
|---|---|
| 通过ID获取单个资产 |
| 获取多个资产 |
| 获取压缩NFT的默克尔证明 |
| 获取多个证明 |
| 钱包下的所有资产 |
| 按创建者地址查询资产 |
| 按权限地址查询资产 |
| 按集合/组查询资产 |
| 带过滤功能的高级搜索 |
| 获取NFT版本信息 |
| 获取代币账户 |
| 资产的交易历史 |
Enhanced Transactions API
增强型交易API
Get parsed, human-readable transaction data.
typescript
// Parse transactions by signature
const parsed = await helius.enhanced.getTransactions({
transactions: ["sig1", "sig2", "sig3"],
});
// Get enhanced transaction history
const history = await helius.enhanced.getTransactionsByAddress({
address: "wallet_address",
type: "SWAP", // Optional: filter by type
});获取已解析、易读的交易数据。
typescript
// Parse transactions by signature
const parsed = await helius.enhanced.getTransactions({
transactions: ["sig1", "sig2", "sig3"],
});
// Get enhanced transaction history
const history = await helius.enhanced.getTransactionsByAddress({
address: "wallet_address",
type: "SWAP", // Optional: filter by type
});Transaction Types
交易类型
- - DEX swaps (Jupiter, Raydium, Orca)
SWAP - - NFT marketplace sales
NFT_SALE - - NFT listings
NFT_LISTING - - NFT bids
NFT_BID - - Token minting
TOKEN_MINT - - SOL/token transfers
TRANSFER - - Staking operations
STAKE - - Unrecognized transactions
UNKNOWN
- - DEX兑换(Jupiter、Raydium、Orca)
SWAP - - NFT市场销售
NFT_SALE - - NFT上架
NFT_LISTING - - NFT出价
NFT_BID - - 代币铸造
TOKEN_MINT - - SOL/代币转账
TRANSFER - - 质押操作
STAKE - - 无法识别的交易
UNKNOWN
Priority Fee API
优先费用API
Get real-time priority fee recommendations.
typescript
// Get priority fee estimate
const feeEstimate = await helius.getPriorityFeeEstimate({
transaction: serializedTransaction, // Base64 encoded
// OR
accountKeys: ["account1", "account2"], // Accounts in transaction
options: {
priorityLevel: "HIGH", // LOW, MEDIUM, HIGH, VERY_HIGH
includeAllPriorityFeeLevels: true,
lookbackSlots: 150,
},
});
console.log(feeEstimate.priorityFeeEstimate); // microLamports获取实时优先费用建议。
typescript
// Get priority fee estimate
const feeEstimate = await helius.getPriorityFeeEstimate({
transaction: serializedTransaction, // Base64 encoded
// OR
accountKeys: ["account1", "account2"], // Accounts in transaction
options: {
priorityLevel: "HIGH", // LOW, MEDIUM, HIGH, VERY_HIGH
includeAllPriorityFeeLevels: true,
lookbackSlots: 150,
},
});
console.log(feeEstimate.priorityFeeEstimate); // microLamportsUsing Priority Fees in Transactions
在交易中使用优先费用
typescript
import { getSetComputeUnitPriceInstruction } from "@solana-program/compute-budget";
// Get estimate
const { priorityFeeEstimate } = await helius.getPriorityFeeEstimate({
accountKeys: [payer.address, recipient.address],
options: { priorityLevel: "HIGH" },
});
// Add to transaction
const priorityFeeIx = getSetComputeUnitPriceInstruction({
microLamports: BigInt(priorityFeeEstimate),
});
// Prepend to transaction instructions
const tx = pipe(
createTransactionMessage({ version: 0 }),
(tx) => setTransactionMessageFeePayer(payer.address, tx),
(tx) => setTransactionMessageLifetimeUsingBlockhash(blockhash, tx),
(tx) => prependTransactionMessageInstructions([priorityFeeIx], tx),
(tx) => appendTransactionMessageInstruction(mainInstruction, tx),
);typescript
import { getSetComputeUnitPriceInstruction } from "@solana-program/compute-budget";
// Get estimate
const { priorityFeeEstimate } = await helius.getPriorityFeeEstimate({
accountKeys: [payer.address, recipient.address],
options: { priorityLevel: "HIGH" },
});
// Add to transaction
const priorityFeeIx = getSetComputeUnitPriceInstruction({
microLamports: BigInt(priorityFeeEstimate),
});
// Prepend to transaction instructions
const tx = pipe(
createTransactionMessage({ version: 0 }),
(tx) => setTransactionMessageFeePayer(payer.address, tx),
(tx) => setTransactionMessageLifetimeUsingBlockhash(blockhash, tx),
(tx) => prependTransactionMessageInstructions([priorityFeeIx], tx),
(tx) => appendTransactionMessageInstruction(mainInstruction, tx),
);Webhooks
Webhook
Real-time blockchain event notifications.
实时区块链事件通知。
Webhook Types
Webhook类型
| Type | Description |
|---|---|
| Enhanced | Parsed, filtered events (NFT sales, swaps, etc.) |
| Raw | Unfiltered transaction data, lower latency |
| Discord | Direct Discord channel notifications |
| 类型 | 描述 |
|---|---|
| Enhanced | 已解析、带过滤的事件(NFT销售、兑换等) |
| Raw | 未过滤的交易数据,延迟更低 |
| Discord | 直接发送至Discord频道的通知 |
Create Webhook
创建Webhook
typescript
// Create enhanced webhook
const webhook = await helius.webhooks.createWebhook({
webhookURL: "https://your-server.com/webhook",
transactionTypes: ["NFT_SALE", "SWAP"],
accountAddresses: ["address1", "address2"],
webhookType: "enhanced",
});
// Create raw webhook
const rawWebhook = await helius.webhooks.createWebhook({
webhookURL: "https://your-server.com/raw-webhook",
accountAddresses: ["address1"],
webhookType: "raw",
});typescript
// Create enhanced webhook
const webhook = await helius.webhooks.createWebhook({
webhookURL: "https://your-server.com/webhook",
transactionTypes: ["NFT_SALE", "SWAP"],
accountAddresses: ["address1", "address2"],
webhookType: "enhanced",
});
// Create raw webhook
const rawWebhook = await helius.webhooks.createWebhook({
webhookURL: "https://your-server.com/raw-webhook",
accountAddresses: ["address1"],
webhookType: "raw",
});Manage Webhooks
管理Webhook
typescript
// Get all webhooks
const webhooks = await helius.webhooks.getAllWebhooks();
// Get specific webhook
const webhook = await helius.webhooks.getWebhookByID({
webhookID: "webhook_id",
});
// Update webhook
await helius.webhooks.updateWebhook({
webhookID: "webhook_id",
webhookURL: "https://new-url.com/webhook",
accountAddresses: ["address1", "address2", "address3"],
});
// Delete webhook
await helius.webhooks.deleteWebhook({
webhookID: "webhook_id",
});typescript
// Get all webhooks
const webhooks = await helius.webhooks.getAllWebhooks();
// Get specific webhook
const webhook = await helius.webhooks.getWebhookByID({
webhookID: "webhook_id",
});
// Update webhook
await helius.webhooks.updateWebhook({
webhookID: "webhook_id",
webhookURL: "https://new-url.com/webhook",
accountAddresses: ["address1", "address2", "address3"],
});
// Delete webhook
await helius.webhooks.deleteWebhook({
webhookID: "webhook_id",
});Webhook Payload (Enhanced)
Webhook负载(Enhanced)
typescript
interface EnhancedWebhookPayload {
accountData: AccountData[];
description: string;
events: Record<string, unknown>;
fee: number;
feePayer: string;
nativeTransfers: NativeTransfer[];
signature: string;
slot: number;
source: string;
timestamp: number;
tokenTransfers: TokenTransfer[];
type: string;
}typescript
interface EnhancedWebhookPayload {
accountData: AccountData[];
description: string;
events: Record<string, unknown>;
fee: number;
feePayer: string;
nativeTransfers: NativeTransfer[];
signature: string;
slot: number;
source: string;
timestamp: number;
tokenTransfers: TokenTransfer[];
type: string;
}ZK Compression API
ZK压缩API
Work with compressed accounts and tokens (Light Protocol).
typescript
// Get compressed account
const account = await helius.zk.getCompressedAccount({
address: "compressed_account_address",
});
// Get compressed token accounts by owner
const tokens = await helius.zk.getCompressedTokenAccountsByOwner({
owner: "wallet_address",
});
// Get compressed balance
const balance = await helius.zk.getCompressedBalance({
address: "compressed_account_address",
});
// Get validity proof
const proof = await helius.zk.getValidityProof({
hashes: ["hash1", "hash2"],
});
// Get compression signatures
const sigs = await helius.zk.getCompressionSignaturesForOwner({
owner: "wallet_address",
limit: 100,
});处理压缩账户与代币(Light Protocol)。
typescript
// Get compressed account
const account = await helius.zk.getCompressedAccount({
address: "compressed_account_address",
});
// Get compressed token accounts by owner
const tokens = await helius.zk.getCompressedTokenAccountsByOwner({
owner: "wallet_address",
});
// Get compressed balance
const balance = await helius.zk.getCompressedBalance({
address: "compressed_account_address",
});
// Get validity proof
const proof = await helius.zk.getValidityProof({
hashes: ["hash1", "hash2"],
});
// Get compression signatures
const sigs = await helius.zk.getCompressionSignaturesForOwner({
owner: "wallet_address",
limit: 100,
});ZK Compression Methods
ZK压缩方法
| Method | Description |
|---|---|
| Get compressed account data |
| Get proof for account |
| All compressed accounts for wallet |
| Get compressed SOL balance |
| Compressed token accounts |
| Token balances |
| Get validity proof for hashes |
| Compression transaction history |
| Check indexer status |
| Current indexed slot |
| 方法 | 描述 |
|---|---|
| 获取压缩账户数据 |
| 获取账户证明 |
| 钱包下的所有压缩账户 |
| 获取压缩SOL余额 |
| 压缩代币账户 |
| 代币余额 |
| 获取哈希的有效性证明 |
| 压缩交易历史 |
| 检查索引器状态 |
| 当前已索引的区块高度 |
Transaction Sending
交易发送
Smart Transaction Sending
智能交易发送
typescript
// Send with automatic retry and optimization
const signature = await helius.tx.sendSmartTransaction({
transaction: signedTransaction,
skipPreflight: false,
maxRetries: 3,
});
// Estimate compute units
const computeUnits = await helius.tx.getComputeUnits({
transaction: serializedTransaction,
});typescript
// Send with automatic retry and optimization
const signature = await helius.tx.sendSmartTransaction({
transaction: signedTransaction,
skipPreflight: false,
maxRetries: 3,
});
// Estimate compute units
const computeUnits = await helius.tx.getComputeUnits({
transaction: serializedTransaction,
});Optimized Transaction Pattern
优化的交易模式
typescript
import { createHelius } from "helius-sdk";
import {
pipe,
createTransactionMessage,
setTransactionMessageFeePayer,
setTransactionMessageLifetimeUsingBlockhash,
appendTransactionMessageInstruction,
signTransactionMessageWithSigners,
getBase64EncodedWireTransaction,
} from "@solana/kit";
import {
getSetComputeUnitLimitInstruction,
getSetComputeUnitPriceInstruction,
} from "@solana-program/compute-budget";
async function sendOptimizedTransaction(
helius: ReturnType<typeof createHelius>,
rpc: Rpc,
signer: KeyPairSigner,
instruction: IInstruction
) {
// 1. Get priority fee
const { priorityFeeEstimate } = await helius.getPriorityFeeEstimate({
accountKeys: [signer.address],
options: { priorityLevel: "HIGH" },
});
// 2. Get blockhash
const { value: blockhash } = await rpc.getLatestBlockhash().send();
// 3. Build transaction with compute budget
const tx = pipe(
createTransactionMessage({ version: 0 }),
(tx) => setTransactionMessageFeePayer(signer.address, tx),
(tx) => setTransactionMessageLifetimeUsingBlockhash(blockhash, tx),
(tx) => prependTransactionMessageInstructions([
getSetComputeUnitLimitInstruction({ units: 200_000 }),
getSetComputeUnitPriceInstruction({ microLamports: BigInt(priorityFeeEstimate) }),
], tx),
(tx) => appendTransactionMessageInstruction(instruction, tx),
);
// 4. Sign
const signedTx = await signTransactionMessageWithSigners(tx);
// 5. Send via Helius
const signature = await helius.tx.sendSmartTransaction({
transaction: getBase64EncodedWireTransaction(signedTx),
});
return signature;
}typescript
import { createHelius } from "helius-sdk";
import {
pipe,
createTransactionMessage,
setTransactionMessageFeePayer,
setTransactionMessageLifetimeUsingBlockhash,
appendTransactionMessageInstruction,
signTransactionMessageWithSigners,
getBase64EncodedWireTransaction,
} from "@solana/kit";
import {
getSetComputeUnitLimitInstruction,
getSetComputeUnitPriceInstruction,
} from "@solana-program/compute-budget";
async function sendOptimizedTransaction(
helius: ReturnType<typeof createHelius>,
rpc: Rpc,
signer: KeyPairSigner,
instruction: IInstruction
) {
// 1. Get priority fee
const { priorityFeeEstimate } = await helius.getPriorityFeeEstimate({
accountKeys: [signer.address],
options: { priorityLevel: "HIGH" },
});
// 2. Get blockhash
const { value: blockhash } = await rpc.getLatestBlockhash().send();
// 3. Build transaction with compute budget
const tx = pipe(
createTransactionMessage({ version: 0 }),
(tx) => setTransactionMessageFeePayer(signer.address, tx),
(tx) => setTransactionMessageLifetimeUsingBlockhash(blockhash, tx),
(tx) => prependTransactionMessageInstructions([
getSetComputeUnitLimitInstruction({ units: 200_000 }),
getSetComputeUnitPriceInstruction({ microLamports: BigInt(priorityFeeEstimate) }),
], tx),
(tx) => appendTransactionMessageInstruction(instruction, tx),
);
// 4. Sign
const signedTx = await signTransactionMessageWithSigners(tx);
// 5. Send via Helius
const signature = await helius.tx.sendSmartTransaction({
transaction: getBase64EncodedWireTransaction(signedTx),
});
return signature;
}WebSocket Subscriptions
WebSocket订阅
Real-time data streaming via WebSocket.
typescript
// Subscribe to account changes
const accountSub = await helius.ws.accountNotifications({
account: "account_address",
commitment: "confirmed",
callback: (notification) => {
console.log("Account changed:", notification);
},
});
// Subscribe to logs
const logsSub = await helius.ws.logsNotifications({
filter: { mentions: ["program_id"] },
commitment: "confirmed",
callback: (logs) => {
console.log("Logs:", logs);
},
});
// Subscribe to signature confirmations
const sigSub = await helius.ws.signatureNotifications({
signature: "transaction_signature",
commitment: "confirmed",
callback: (status) => {
console.log("Confirmed:", status);
},
});
// Unsubscribe
await accountSub.unsubscribe();通过WebSocket实现实时数据流。
typescript
// Subscribe to account changes
const accountSub = await helius.ws.accountNotifications({
account: "account_address",
commitment: "confirmed",
callback: (notification) => {
console.log("Account changed:", notification);
},
});
// Subscribe to logs
const logsSub = await helius.ws.logsNotifications({
filter: { mentions: ["program_id"] },
commitment: "confirmed",
callback: (logs) => {
console.log("Logs:", logs);
},
});
// Subscribe to signature confirmations
const sigSub = await helius.ws.signatureNotifications({
signature: "transaction_signature",
commitment: "confirmed",
callback: (status) => {
console.log("Confirmed:", status);
},
});
// Unsubscribe
await accountSub.unsubscribe();LaserStream (gRPC)
LaserStream(gRPC)
LaserStream is a next-generation gRPC streaming service - a drop-in replacement for Yellowstone that adds historical replay, auto-reconnect, and multi-region endpoints.
LaserStream是下一代gRPC流服务——可直接替代Yellowstone,增加了历史回放、自动重连和多区域端点功能。
Features
特性
- Ultra-low latency: Taps directly into Solana leaders to receive shreds as they're produced
- Historical replay: Replay past blocks and transactions
- Auto-reconnect: Automatic failover and recovery
- Redundant node clusters: High availability infrastructure
- Regional endpoints: Global coverage for minimal latency
- Block, transaction, and account streaming
- 超低延迟:直接对接Solana领导者节点,在分片生成时立即接收
- 历史回放:回放过去的区块与交易
- 自动重连:自动故障转移与恢复
- 冗余节点集群:高可用基础设施
- 区域端点:全球覆盖,延迟最小化
- 区块、交易与账户流
Endpoints
端点
| Region | Endpoint |
|---|---|
| Frankfurt | |
| Amsterdam | |
| Tokyo | |
| Singapore | |
| Los Angeles | |
| London | |
| Newark | |
| Pittsburgh | |
| Salt Lake City | |
| 地区 | 端点 |
|---|---|
| 法兰克福 | |
| 阿姆斯特丹 | |
| 东京 | |
| 新加坡 | |
| 洛杉矶 | |
| 伦敦 | |
| 纽瓦克 | |
| 匹兹堡 | |
| 盐湖城 | |
Atlas Infrastructure
Atlas基础设施
Atlas endpoints provide the backbone for Enhanced WebSockets and high-performance streaming:
typescript
// Atlas WebSocket endpoints
const ATLAS_MAINNET_WS = "wss://atlas-mainnet.helius-rpc.com";
const ATLAS_DEVNET_WS = "wss://atlas-devnet.helius-rpc.com";Atlas端点为增强型WebSocket和高性能流提供支撑:
typescript
// Atlas WebSocket endpoints
const ATLAS_MAINNET_WS = "wss://atlas-mainnet.helius-rpc.com";
const ATLAS_DEVNET_WS = "wss://atlas-devnet.helius-rpc.com";Enhanced WebSockets (New)
增强型WebSocket(新版)
Enhanced WebSockets are now powered by LaserStream infrastructure, offering:
- 1.5–2× faster than standard WebSockets
- gRPC reliability in a WebSocket wrapper
- Same filtering and event types as regular WebSockets
typescript
// Connect to Enhanced WebSocket
const ws = new WebSocket(
`wss://atlas-mainnet.helius-rpc.com/?api-key=${process.env.HELIUS_API_KEY}`
);
ws.on("open", () => {
// Subscribe to account changes
ws.send(JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "accountSubscribe",
params: [accountAddress, { commitment: "confirmed" }],
}));
});增强型WebSocket现在由LaserStream基础设施提供支持,具备以下优势:
- 比标准WebSocket 快1.5–2倍
- 在WebSocket封装中提供gRPC级别的可靠性
- 与常规WebSocket支持相同的过滤和事件类型
typescript
// Connect to Enhanced WebSocket
const ws = new WebSocket(
`wss://atlas-mainnet.helius-rpc.com/?api-key=${process.env.HELIUS_API_KEY}`
);
ws.on("open", () => {
// Subscribe to account changes
ws.send(JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "accountSubscribe",
params: [accountAddress, { commitment: "confirmed" }],
}));
});Shred Delivery (Beta)
分片交付(测试版)
For teams chasing single-digit millisecond latency, Helius offers a UDP feed of raw shreds directly from validators.
对于追求个位数毫秒延迟的团队,Helius提供直接从验证器获取的原始分片UDP流。
Staking API
质押API
Stake SOL with Helius validator programmatically.
typescript
// Create stake transaction
const stakeTx = await helius.staking.createStakeTransaction({
payerAddress: "wallet_address",
amount: 1_000_000_000, // 1 SOL in lamports
});
// Create unstake transaction
const unstakeTx = await helius.staking.createUnstakeTransaction({
payerAddress: "wallet_address",
stakeAccountAddress: "stake_account",
});
// Get stake accounts
const stakeAccounts = await helius.staking.getHeliusStakeAccounts({
ownerAddress: "wallet_address",
});通过Helius验证器以编程方式质押SOL。
typescript
// Create stake transaction
const stakeTx = await helius.staking.createStakeTransaction({
payerAddress: "wallet_address",
amount: 1_000_000_000, // 1 SOL in lamports
});
// Create unstake transaction
const unstakeTx = await helius.staking.createUnstakeTransaction({
payerAddress: "wallet_address",
stakeAccountAddress: "stake_account",
});
// Get stake accounts
const stakeAccounts = await helius.staking.getHeliusStakeAccounts({
ownerAddress: "wallet_address",
});SDK Namespaces
SDK命名空间
| Namespace | Purpose |
|---|---|
| DAS API, priority fees |
| Enhanced RPC methods |
| Transaction operations |
| Validator staking |
| Decoded transaction data |
| Event management |
| WebSocket subscriptions |
| ZK Compression features |
| 命名空间 | 用途 |
|---|---|
| DAS API、优先费用 |
| 增强型RPC方法 |
| 交易操作 |
| 验证器质押 |
| 解码后的交易数据 |
| 事件管理 |
| WebSocket订阅 |
| ZK压缩功能 |
Error Handling
错误处理
typescript
try {
const assets = await helius.getAssetsByOwner({ ownerAddress: "..." });
} catch (error) {
if (error.response?.status === 401) {
console.error("Invalid API key");
} else if (error.response?.status === 429) {
console.error("Rate limited - upgrade plan or reduce requests");
} else if (error.response?.status >= 500) {
console.error("Helius server error - retry later");
}
}typescript
try {
const assets = await helius.getAssetsByOwner({ ownerAddress: "..." });
} catch (error) {
if (error.response?.status === 401) {
console.error("Invalid API key");
} else if (error.response?.status === 429) {
console.error("Rate limited - upgrade plan or reduce requests");
} else if (error.response?.status >= 500) {
console.error("Helius server error - retry later");
}
}Common Error Codes
常见错误码
| Code | Meaning | Solution |
|---|---|---|
| 401 | Invalid API key | Check key in dashboard |
| 429 | Rate limited | Upgrade plan or add delays |
| 500+ | Server error | Retry with backoff |
| 代码 | 含义 | 解决方案 |
|---|---|---|
| 401 | API密钥无效 | 在控制台检查密钥 |
| 429 | 请求超限 | 升级套餐或减少请求频率 |
| 500+ | 服务器错误 | 稍后重试,使用指数退避策略 |
Rate Limits & Pricing
请求限制与定价
| Plan | Credits/Month | RPC Calls | Webhooks |
|---|---|---|---|
| Free | 500,000 | Standard | 2 |
| Developer | 5M | Enhanced | 10 |
| Growth | 50M | Priority | 50 |
| Enterprise | Custom | Dedicated | Unlimited |
| 套餐 | 每月积分 | RPC调用 | Webhook |
|---|---|---|---|
| 免费版 | 500,000 | 标准型 | 2个 |
| 开发者版 | 5,000,000 | 增强型 | 10个 |
| 成长版 | 50,000,000 | 优先型 | 50个 |
| 企业版 | 定制 | 专属型 | 无限 |
Credit Costs
积分成本
- Standard RPC: 1 credit/call
- DAS API: 1-10 credits/call
- Webhooks: 1 credit/event delivered
- Webhook management: 100 credits/operation
- 标准RPC:1积分/调用
- DAS API:1-10积分/调用
- Webhook:1积分/已交付事件
- Webhook管理:100积分/操作
Best Practices
最佳实践
API Key Security
API密钥安全
- Never commit API keys to git
- Use environment variables
- Rotate keys periodically
- Use separate keys for dev/prod
- 切勿将API密钥提交至git
- 使用环境变量存储
- 定期轮换密钥
- 为开发/生产环境使用不同的密钥
Performance
性能优化
- Batch requests when possible (getAssetBatch, getAssetProofBatch)
- Use cursor-based pagination for large datasets
- Cache frequently accessed data
- Use appropriate commitment levels
- 尽可能批量请求(getAssetBatch、getAssetProofBatch)
- 对大型数据集使用基于游标的分页
- 缓存频繁访问的数据
- 使用合适的确认级别
Reliability
可靠性
- Implement retry logic with exponential backoff
- Handle rate limits gracefully
- Use multiple regional endpoints for failover
- Monitor webhook delivery and handle retries
- 实现带指数退避的重试逻辑
- 优雅处理请求超限
- 使用多区域端点实现故障转移
- 监控Webhook交付并处理重试
Resources
资源
Skill Structure
技能结构
helius/
├── SKILL.md # This file
├── resources/
│ ├── rpc-methods.md # Complete RPC reference
│ ├── das-api.md # DAS API reference
│ ├── enhanced-apis.md # Enhanced transactions & priority fees
│ ├── webhooks.md # Webhook configuration
│ ├── zk-compression.md # ZK compression API
│ └── sdk-reference.md # SDK namespace reference
├── examples/
│ ├── basic-rpc/ # Basic RPC calls
│ ├── fetch-nfts/ # DAS API examples
│ ├── send-transactions/ # Transaction sending
│ ├── webhooks/ # Webhook setup
│ └── streaming/ # Real-time data
├── templates/
│ └── helius-setup.ts # Starter template
└── docs/
└── troubleshooting.md # Common issueshelius/
├── SKILL.md # 本文档
├── resources/
│ ├── rpc-methods.md # 完整RPC参考
│ ├── das-api.md # DAS API参考
│ ├── enhanced-apis.md # 增强型API与优先费用
│ ├── webhooks.md # Webhook配置
│ ├── zk-compression.md # ZK压缩API
│ └── sdk-reference.md # SDK命名空间参考
├── examples/
│ ├── basic-rpc/ # 基础RPC调用示例
│ ├── fetch-nfts/ # DAS API示例
│ ├── send-transactions/ # 交易发送示例
│ ├── webhooks/ # Webhook设置示例
│ └── streaming/ # 实时数据流示例
├── templates/
│ └── helius-setup.ts # 入门模板
└── docs/
└── troubleshooting.md # 常见问题