helius

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Helius 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
undefined
bash
undefined

Install 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
undefined
pnpm add helius-sdk
undefined

Get Your API Key

获取API密钥

  1. Visit dashboard.helius.dev
  2. Create an account or sign in
  3. Generate an API key
  4. Store it securely (never commit to git)
  1. 访问 dashboard.helius.dev
  2. 创建账户或登录
  3. 生成API密钥
  4. 安全存储(切勿提交至git)

Environment Setup

环境配置

bash
undefined
bash
undefined

.env file

.env file

HELIUS_API_KEY=your_api_key_here
undefined
HELIUS_API_KEY=your_api_key_here
undefined

Basic 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

端点

NetworkHTTP EndpointWebSocket Endpoint
Mainnet
https://mainnet.helius-rpc.com/?api-key=<KEY>
wss://mainnet.helius-rpc.com/?api-key=<KEY>
Devnet
https://devnet.helius-rpc.com/?api-key=<KEY>
wss://devnet.helius-rpc.com/?api-key=<KEY>
网络HTTP端点WebSocket端点
主网
https://mainnet.helius-rpc.com/?api-key=<KEY>
wss://mainnet.helius-rpc.com/?api-key=<KEY>
测试网
https://devnet.helius-rpc.com/?api-key=<KEY>
wss://devnet.helius-rpc.com/?api-key=<KEY>

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方法

MethodDescription
getProgramAccountsV2
Cursor-based pagination for program accounts
getTokenAccountsByOwnerV2
Efficient token account retrieval
getTransactionsForAddress
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
});
方法描述
getProgramAccountsV2
基于游标の程序账户分页查询
getTokenAccountsByOwnerV2
高效检索代币账户
getTransactionsForAddress
带过滤功能の高级交易历史查询
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方法参考

MethodDescription
getAsset
Get single asset by ID
getAssetBatch
Get multiple assets
getAssetProof
Get merkle proof for cNFT
getAssetProofBatch
Get multiple proofs
getAssetsByOwner
All assets for wallet
getAssetsByCreator
Assets by creator address
getAssetsByAuthority
Assets by authority
getAssetsByGroup
Assets by collection/group
searchAssets
Advanced search with filters
getNftEditions
Get NFT edition info
getTokenAccounts
Get token accounts
getSignaturesForAsset
Transaction history for asset
方法描述
getAsset
通过ID获取单个资产
getAssetBatch
获取多个资产
getAssetProof
获取压缩NFT的默克尔证明
getAssetProofBatch
获取多个证明
getAssetsByOwner
钱包下的所有资产
getAssetsByCreator
按创建者地址查询资产
getAssetsByAuthority
按权限地址查询资产
getAssetsByGroup
按集合/组查询资产
searchAssets
带过滤功能的高级搜索
getNftEditions
获取NFT版本信息
getTokenAccounts
获取代币账户
getSignaturesForAsset
资产的交易历史

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

交易类型

  • SWAP
    - DEX swaps (Jupiter, Raydium, Orca)
  • NFT_SALE
    - NFT marketplace sales
  • NFT_LISTING
    - NFT listings
  • NFT_BID
    - NFT bids
  • TOKEN_MINT
    - Token minting
  • TRANSFER
    - SOL/token transfers
  • STAKE
    - Staking operations
  • UNKNOWN
    - Unrecognized transactions
  • SWAP
    - DEX兑换(Jupiter、Raydium、Orca)
  • NFT_SALE
    - NFT市场销售
  • NFT_LISTING
    - NFT上架
  • NFT_BID
    - NFT出价
  • TOKEN_MINT
    - 代币铸造
  • TRANSFER
    - SOL/代币转账
  • 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); // microLamports

Using 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类型

TypeDescription
EnhancedParsed, filtered events (NFT sales, swaps, etc.)
RawUnfiltered transaction data, lower latency
DiscordDirect 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压缩方法

MethodDescription
getCompressedAccount
Get compressed account data
getCompressedAccountProof
Get proof for account
getCompressedAccountsByOwner
All compressed accounts for wallet
getCompressedBalance
Get compressed SOL balance
getCompressedTokenAccountsByOwner
Compressed token accounts
getCompressedTokenBalancesByOwner
Token balances
getValidityProof
Get validity proof for hashes
getCompressionSignaturesForOwner
Compression transaction history
getIndexerHealth
Check indexer status
getIndexerSlot
Current indexed slot
方法描述
getCompressedAccount
获取压缩账户数据
getCompressedAccountProof
获取账户证明
getCompressedAccountsByOwner
钱包下的所有压缩账户
getCompressedBalance
获取压缩SOL余额
getCompressedTokenAccountsByOwner
压缩代币账户
getCompressedTokenBalancesByOwner
代币余额
getValidityProof
获取哈希的有效性证明
getCompressionSignaturesForOwner
压缩交易历史
getIndexerHealth
检查索引器状态
getIndexerSlot
当前已索引的区块高度

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

端点

RegionEndpoint
Frankfurt
fra.laserstream.helius.dev
Amsterdam
ams.laserstream.helius.dev
Tokyo
tyo.laserstream.helius.dev
Singapore
sg.laserstream.helius.dev
Los Angeles
lax.laserstream.helius.dev
London
lon.laserstream.helius.dev
Newark
ewr.laserstream.helius.dev
Pittsburgh
pitt.laserstream.helius.dev
Salt Lake City
slc.laserstream.helius.dev
地区端点
法兰克福
fra.laserstream.helius.dev
阿姆斯特丹
ams.laserstream.helius.dev
东京
tyo.laserstream.helius.dev
新加坡
sg.laserstream.helius.dev
洛杉矶
lax.laserstream.helius.dev
伦敦
lon.laserstream.helius.dev
纽瓦克
ewr.laserstream.helius.dev
匹兹堡
pitt.laserstream.helius.dev
盐湖城
slc.laserstream.helius.dev

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命名空间

NamespacePurpose
helius.*
DAS API, priority fees
helius.rpc.*
Enhanced RPC methods
helius.tx.*
Transaction operations
helius.staking.*
Validator staking
helius.enhanced.*
Decoded transaction data
helius.webhooks.*
Event management
helius.ws.*
WebSocket subscriptions
helius.zk.*
ZK Compression features
命名空间用途
helius.*
DAS API、优先费用
helius.rpc.*
增强型RPC方法
helius.tx.*
交易操作
helius.staking.*
验证器质押
helius.enhanced.*
解码后的交易数据
helius.webhooks.*
事件管理
helius.ws.*
WebSocket订阅
helius.zk.*
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

常见错误码

CodeMeaningSolution
401Invalid API keyCheck key in dashboard
429Rate limitedUpgrade plan or add delays
500+Server errorRetry with backoff
代码含义解决方案
401API密钥无效在控制台检查密钥
429请求超限升级套餐或减少请求频率
500+服务器错误稍后重试,使用指数退避策略

Rate Limits & Pricing

请求限制与定价

PlanCredits/MonthRPC CallsWebhooks
Free500,000Standard2
Developer5MEnhanced10
Growth50MPriority50
EnterpriseCustomDedicatedUnlimited
套餐每月积分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 issues
helius/
├── 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      # 常见问题