Documentation Index
Fetch the complete documentation index at: https://docs.solanatracker.io/llms.txt
Use this file to discover all available pages before exploring further.
获取您的 API 密钥
订阅服务
独立 gRPC 方案 €200/月,或与 RPC Business、Professional 方案免费捆绑。详见 定价与限制。你将获得以下访问权限:
- 欧盟端点:
https://grpc.solanatracker.io
- 美国端点:
https://grpc-us.solanatracker.io
- 通过 Jito Shreds 加速
- 无带宽费用
测试连接
通过创建简单的测试连接验证您的凭据是否有效
身份验证方法
基于请求头的身份验证
将您的 API 令牌添加到请求头中:
客户端配置
TypeScript/JavaScript
npm install @triton-one/yellowstone-grpc
import Client from "@triton-one/yellowstone-grpc";
const client = new Client(
"https://grpc.solanatracker.io", // or https://grpc-us.solanatracker.io
"your-api-token",
{
// Recommended settings
"grpc.max_receive_message_length": 64 * 1024 * 1024, // 64MB
"grpc.max_send_message_length": 64 * 1024 * 1024, // 64MB
"grpc.keepalive_time_ms": 30000, // 30 seconds
"grpc.keepalive_timeout_ms": 5000, // 5 seconds
}
);
Rust
[dependencies]
yellowstone-grpc-client = "9.0.1"
yellowstone-grpc-proto = "9.0.1"
tokio = { version = "1.0", features = ["full"] }
tonic = "0.10"
use yellowstone_grpc_client::GeyserGrpcClient;
use std::time::Duration;
let endpoint = "https://grpc.solanatracker.io";
let token = Some("your-api-token".to_string());
let client = GeyserGrpcClient::build_from_shared(endpoint)?
.x_token(token)?
.connect_timeout(Duration::from_secs(10))
.timeout(Duration::from_secs(10))
.max_decoding_message_size(64 * 1024 * 1024)
.connect()
.await?;
go get github.com/rpcpool/yellowstone-grpc/examples/golang@latest
go get google.golang.org/grpc@v1.67.1
import (
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
)
conn, err := grpc.Dial(
"grpc.solanatracker.io:443",
grpc.WithTransportCredentials(credentials.NewClientTLSFromCert(nil, "")),
grpc.WithDefaultCallOptions(
grpc.MaxCallRecvMsgSize(64 * 1024 * 1024),
grpc.MaxCallSendMsgSize(64 * 1024 * 1024),
),
)
// Add authentication
ctx := metadata.AppendToOutgoingContext(context.Background(), "x-token", "your-api-token")
端点选择
选择为您的基础设施提供最佳延迟的端点:
配置最佳实践
消息大小限制
设置适当的消息大小限制以处理大区块和交易批次:
{
"grpc.max_receive_message_length": 64 * 1024 * 1024, // 64MB
"grpc.max_send_message_length": 64 * 1024 * 1024 // 64MB
}
Keepalive 设置
配置 keepalive 以维持持久连接:
{
"grpc.keepalive_time_ms": 30000, // Send keepalive every 30s
"grpc.keepalive_timeout_ms": 5000, // Wait 5s for keepalive response
"grpc.keepalive_permit_without_calls": 1 // Allow keepalive without active calls
}
连接超时
设置合理的超时值:
{
"grpc.initial_reconnect_backoff_ms": 1000, // Start with 1s backoff
"grpc.max_reconnect_backoff_ms": 30000, // Max 30s backoff
"grpc.min_reconnect_backoff_ms": 1000 // Min 1s backoff
}
测试您的连接
创建一个简单的测试来验证您的设置:
import Client, { CommitmentLevel } from "@triton-one/yellowstone-grpc";
async function testConnection() {
const client = new Client(
"https://grpc.solanatracker.io",
"your-api-token",
{
"grpc.max_receive_message_length": 64 * 1024 * 1024
}
);
try {
const stream = await client.subscribe();
stream.on("data", (data) => {
console.log("Connection successful! Received data:", data);
stream.end();
client.close();
process.exit(0);
});
stream.on("error", (error) => {
console.error("Connection error:", error);
process.exit(1);
});
// Subscribe to slot updates (lightweight test)
const request = {
slots: { slotSubscribe: {} },
commitment: CommitmentLevel.CONFIRMED
};
stream.write(request);
console.log("Testing connection...");
} catch (error) {
console.error("Failed to connect:", error);
process.exit(1);
}
}
testConnection();
故障排除
错误: UNAUTHENTICATED 或 Invalid token解决方案:
- 验证您的 API 令牌是否正确
- 检查令牌是否正确设置在请求头中
- 确保订阅有效
错误: 连接超时或无法建立解决方案:
- 验证端点 URL 正确(包括
https://)
- 检查防火墙是否允许出站 gRPC 连接
- 尝试备用端点
- 增加连接超时设置
错误: RESOURCE_EXHAUSTED 或消息大小错误解决方案:
- 将
max_receive_message_length 增加到 64MB
- 将
max_send_message_length 增加到 64MB
- 使用数据切片减少消息大小
- 应用更具体的过滤器
安全最佳实践
保护您的 API 令牌
- 切勿将令牌提交到版本控制中
- 使用环境变量存储令牌
- 定期轮换令牌
- 实施令牌管理系统
环境变量
安全地存储您的凭据:
# .env file
GRPC_ENDPOINT=https://grpc.solanatracker.io
GRPC_API_TOKEN=your-api-token
import * as dotenv from 'dotenv';
dotenv.config();
const client = new Client(
process.env.GRPC_ENDPOINT!,
process.env.GRPC_API_TOKEN!,
{ /* ... */ }
);
下一步