### Install Go Client Source: https://www.helius.dev/docs/laserstream/clients Install the Helius LaserStream Go client using the go get command. ```bash go get github.com/helius-labs/laserstream-sdk/go ``` -------------------------------- ### Solana RPC API - Fastest Setup Source: https://www.helius.dev/docs/api-reference/rpc/http/llms.txt Example of how to set up and make a request to the Helius Solana RPC API using the standard endpoint. ```APIDOC ## POST /rpc ### Description This endpoint allows you to interact with the Solana blockchain using JSON-RPC 2.0 methods. It supports both standard Solana methods and Helius-enhanced methods. ### Method POST ### Endpoint `https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY` ### Parameters #### Query Parameters - **api-key** (string) - Required - Your Helius API key. #### Request Body - **jsonrpc** (string) - Required - The JSON-RPC protocol version, typically "2.0". - **id** (integer) - Required - A unique identifier for the request. - **method** (string) - Required - The RPC method to call (e.g., "getBalance", "getTransaction"). - **params** (array) - Optional - An array of parameters required by the RPC method. ### Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "getBalance", "params": ["83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"] } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - The JSON-RPC protocol version. - **id** (integer) - The identifier for the request. - **result** (object) - The result of the RPC method call. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": { "value": 1234567890 // Example balance in lamports } } ``` ``` -------------------------------- ### Fetch Blocks from Start Slot to Latest (@solana/web3.js) Source: https://www.helius.dev/docs/rpc/guides/getblocks This JavaScript example uses @solana/web3.js to fetch confirmed block slot numbers from a given start slot up to the latest confirmed slot. The end slot parameter is omitted. Ensure the range does not exceed the 500,000 slot limit. ```javascript const { Connection } = require('@solana/web3.js'); async function getBlocksFromStart(startSlot) { const connection = new Connection('https://mainnet.helius-rpc.com/?api-key='); try { // The endSlot parameter is omitted to fetch up to the latest confirmed block const blocks = await connection.getBlocks(startSlot); console.log(`Confirmed blocks from slot ${startSlot} to latest:`, blocks); if (blocks.length > 0) { console.log(`Latest block in range: ${blocks[blocks.length - 1]}`); } } catch (error) { console.error('Error fetching blocks:', error); } } // Example usage (ensure this doesn't exceed the 500,000 slot limit from latest block): const recentStartSlot = 260000000; getBlocksFromStart(recentStartSlot); ``` -------------------------------- ### Set up Solana NFT Project Source: https://www.helius.dev/docs/quickstart Initializes a new Node.js project for an NFT viewer and installs the necessary `node-fetch` package. ```bash mkdir solana-nft-viewer cd solana-nft-viewer npm init -y npm install node-fetch ``` -------------------------------- ### Standard WebSockets API - Getting Started Source: https://www.helius.dev/docs/api-reference/rpc/websocket/llms.txt Connect to the Helius WebSocket endpoint and send a subscription request to receive real-time blockchain data. This example demonstrates subscribing to account data changes. ```APIDOC ## Getting Started with Helius Standard WebSockets ### Description Connect to the Helius WebSocket endpoint and send a subscription request to receive real-time blockchain data. This example demonstrates subscribing to account data changes. ### Setup 1. Obtain an API key from the Helius dashboard. 2. Connect to the appropriate WebSocket endpoint (Mainnet: `wss://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY`, Devnet: `wss://devnet.helius-rpc.com/?api-key=YOUR_API_KEY`). 3. Send a JSON-RPC request to subscribe to data. 4. Receive real-time updates via WebSocket messages. ### Request Example (JavaScript) ```javascript const WebSocket = require('ws'); const ws = new WebSocket('wss://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY'); ws.on('open', () => { ws.send(JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'accountSubscribe', params: [ 'ACCOUNT_ADDRESS', // Replace with the account address you want to subscribe to { encoding: 'jsonParsed', commitment: 'confirmed' } ] })); }); ws.on('message', (data) => { const response = JSON.parse(data); if (response.method === 'accountNotification') { console.log('Account updated:', response.params.result); } }); ``` ### Use Cases - Monitor wallet balance changes - Track token account updates - Watch program account changes - Confirm transaction signatures - Stream new blocks and slots - Monitor logs for specific programs ``` -------------------------------- ### Docs & Guides API Source: https://www.helius.dev/docs/agents/mcp/tools Search Helius documentation, get credit and rate limit info, troubleshoot errors, and get product-specific guides. ```APIDOC ## Docs & Guides API ### Description Search Helius documentation, get credit and rate limit info, troubleshoot errors, and get product-specific guides. ### Methods #### `lookupHeliusDocs` ##### Description Search Helius documentation. ##### Endpoint `/docs/search` (example) ##### Method GET ##### Query Parameters - **query** (string) - Required - The search query. #### `listHeliusDocTopics` ##### Description List available doc topics. ##### Endpoint `/docs/topics` (example) ##### Method GET #### `getHeliusCreditsInfo` ##### Description Get credit cost information. ##### Endpoint `/credits/info` (example) ##### Method GET #### `getRateLimitInfo` ##### Description Get rate limit details. ##### Endpoint `/limits/rate` (example) ##### Method GET #### `troubleshootError` ##### Description Diagnose an error code. ##### Endpoint `/errors/troubleshoot` (example) ##### Method GET ##### Query Parameters - **errorCode** (string) - Required - The error code to diagnose. #### `getSenderInfo` ##### Description Get Sender documentation. ##### Endpoint `/guides/sender` (example) ##### Method GET #### `getWebhookGuide` ##### Description Get webhook setup guide. ##### Endpoint `/guides/webhook` (example) ##### Method GET #### `getLatencyComparison` ##### Description Compare latency across products. ##### Endpoint `/guides/latency` (example) ##### Method GET #### `getPumpFunGuide` ##### Description Get pump.fun integration guide. ##### Endpoint `/guides/pumpfun` (example) ##### Method GET #### `recommendStack` ##### Description Get recommended Helius stack for your use case. ##### Endpoint `/guides/recommendations` (example) ##### Method GET ##### Query Parameters - **useCase** (string) - Required - The use case for recommendations. ``` -------------------------------- ### Main Application Setup with StreamManager Source: https://www.helius.dev/docs/grpc/quickstart Example `main.ts` file demonstrating how to initialize and use the StreamManager to subscribe to account updates for a specific token mint. Ensure you replace placeholder endpoint and API key. ```typescript import { StreamManager } from './stream-manager'; import { CommitmentLevel, SubscribeRequest } from "@triton-one/yellowstone-grpc"; // Configuration const ENDPOINT = "your-grpc-endpoint"; // LaserStream or Dedicated Node endpoint const API_KEY = "YOUR_API_KEY"; // USDC Token Mint for example const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; async function main() { const streamManager = new StreamManager( ENDPOINT, API_KEY, handleAccountUpdate, handleError ); // Subscribe to USDC mint account updates const subscribeRequest: SubscribeRequest = { accounts: { accountSubscribe: { account: [USDC_MINT], owner: [], filters: [] } }, accountsDataSlice: [], commitment: CommitmentLevel.CONFIRMED, slots: {}, transactions: {}, transactionsStatus: {}, blocks: {}, blocksMeta: {}, entry: {} }; console.log("๐Ÿš€ Starting USDC mint account monitoring..."); ``` -------------------------------- ### Get Version Request Example Source: https://www.helius.dev/docs/api-reference/rpc/http/getversion Example of a JSON-RPC request to retrieve the Helius API version. ```json { "jsonrpc": "2.0", "id": "1", "method": "getVersion" } ``` -------------------------------- ### Make a Simple Balance Query Source: https://www.helius.dev/docs/wallet-api/overview This example demonstrates how to make your first request to the Wallet API to retrieve a wallet's balances. Replace 'YOUR_API_KEY' with your actual API key. ```bash curl "https://api.helius.xyz/v1/wallet/86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY/balances?api-key=YOUR_API_KEY" ``` -------------------------------- ### Initialize TypeScript Project and Install Dependencies Source: https://www.helius.dev/docs/sending-transactions/jupiter-swap-api-via-sender Sets up the development environment by initializing TypeScript, installing necessary Solana and base58 libraries, and configuring type definitions. ```bash npx tsc --init npm install @solana/web3.js bs58 npm install --save-dev @types/node ``` -------------------------------- ### Get Version Response Example Source: https://www.helius.dev/docs/api-reference/rpc/http/getversion Example of a successful JSON-RPC response containing the Helius API version information. ```json { "jsonrpc": "2.0", "id": "1", "result": { "solana-core": "1.16.7", "feature-set": 2891131721 } } ``` -------------------------------- ### Get Supply Request Example Source: https://www.helius.dev/docs/api-reference/rpc/http/getsupply Example of a JSON-RPC request to the getSupply method. Use this to retrieve information about token supply. ```json { "jsonrpc": "2.0", "id": "1", "method": "getSupply", "params": [ { "commitment": "finalized", "excludeNonCirculatingAccountsList": true } ] } ``` -------------------------------- ### Wallet API Authentication Examples Source: https://www.helius.dev/docs/api-reference/wallet-api Examples demonstrating how to authenticate Wallet API requests using either a query parameter or an HTTP header for your API key. The header method is recommended for security. ```bash # Query parameter GET https://api.helius.xyz/v1/wallet/{wallet}/balances?api-key=YOUR_API_KEY ``` ```bash # Header (recommended) GET https://api.helius.xyz/v1/wallet/{wallet}/balances X-Api-Key: YOUR_API_KEY ``` -------------------------------- ### Get Estimated Time of a Specific Block (JavaScript) Source: https://www.helius.dev/docs/rpc/guides/getblocktime Example using JavaScript with the @solana/web3.js library to get the estimated block production time. ```APIDOC ## GET /getBlockTime (JavaScript Example) ### Description This JavaScript example uses the `@solana/web3.js` library to connect to the Helius RPC and retrieve the estimated production time for a given block slot. ### Method POST (via @solana/web3.js Connection) ### Endpoint https://mainnet.helius-rpc.com/?api-key= ### Parameters #### Function Parameters - **slotToQuery** (number) - Required - The slot number of the block for which to retrieve the estimated production time. ### Request Example ```javascript const { Connection } = require('@solana/web3.js'); async function getSpecificBlockTime(slotToQuery) { const connection = new Connection('https://mainnet.helius-rpc.com/?api-key='); try { const blockTime = await connection.getBlockTime(slotToQuery); if (blockTime !== null) { console.log(`Estimated time for slot ${slotToQuery}: ${new Date(blockTime * 1000).toISOString()} (Unix: ${blockTime})`); } else { console.log(`Timestamp not available for slot ${slotToQuery}.`); } } catch (error) { console.error('Error fetching block time:', error); } } // Example usage: Replace with a recent, valid slot number from Mainnet Beta const slotToQuery = 300000000; // Replace with an actual slot number getSpecificBlockTime(slotToQuery); ``` ### Response #### Success Response - **blockTime** (number | null) - The estimated production time as a Unix timestamp (seconds since the Unix epoch), or `null` if not available. ``` -------------------------------- ### Get Supply Response Example Source: https://www.helius.dev/docs/api-reference/rpc/http/getsupply Example of a successful JSON-RPC response for the getSupply method. It includes total, circulating, and non-circulating supply details. ```json { "jsonrpc": "2.0", "id": "1", "result": { "context": { "slot": 1114 }, "value": { "total": 1016000, "circulating": 16000, "nonCirculating": 1000000, "nonCirculatingAccounts": [ "FEy8pTbP5fEoqMV1GdTz83byuA8EKByqYat1PKDgVAq5", "9huDUZfxoJ7wGMTffUE7vh1xePqef7gyrLJu9NApncqA", "3mi1GmwEE3zo2jmfDuzvjSX9ovRXsDUKHvsntpkhuLJ9", "BYxEJTDerkaRWBem3XgnVcdhppktBXa2HbkHPKj2Ui4Z" ] } } } ``` -------------------------------- ### Full Agent Workflow Example Source: https://www.helius.dev/docs/agents/cli This sequence demonstrates a typical workflow for setting up and using Helius agents, from generating a keypair and funding a wallet to creating an account, obtaining API keys and RPC endpoints, and finally performing basic queries. ```bash # Step 1: Generate keypair helius keygen # Step 2: Fund wallet externally # Send ~0.001 SOL + 1 USDC to the address # Step 3: Create account helius signup # Step 4: Get API keys helius projects helius apikeys # Step 5: Get RPC endpoints helius rpc # Step 6: Start querying helius balance
helius asset owner helius tx history
--limit 10 ``` -------------------------------- ### Basic Transaction Monitoring Stream Setup Source: https://www.helius.dev/docs/grpc This TypeScript example demonstrates how to set up a gRPC stream for monitoring transactions. It includes client initialization, stream subscription, and handling incoming transaction data. For production, implement robust error handling and reconnection logic. ```typescript import Client, { CommitmentLevel, SubscribeRequest } from "@triton-one/yellowstone-grpc"; const client = new Client("your-grpc-endpoint", "your-api-token", { "grpc.max_receive_message_length": 64 * 1024 * 1024 }); const stream = await client.subscribe(); // Handle incoming data stream.on("data", (data) => { if (data.transaction) { console.log(`Transaction: ${data.transaction.signature}`); console.log(`Success: ${!data.transaction.meta?.err}`); } }); // Subscribe to transactions with complete request structure const subscribeRequest: SubscribeRequest = { transactions: { client: { accountInclude: [ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", // Token Program "11111111111111111111111111111111" // System Program ], accountExclude: [], accountRequired: [], vote: false, failed: false } }, commitment: CommitmentLevel.CONFIRMED, ping: { id: 1 } }; stream.write(subscribeRequest); ``` -------------------------------- ### Get Token Account Balance Request Example Source: https://www.helius.dev/docs/api-reference/rpc/http/gettokenaccountbalance Example JSON payload for the `getTokenAccountBalance` method. This demonstrates the required parameters for querying a token balance. ```json { "jsonrpc": "2.0", "id": "1", "method": "getTokenAccountBalance", "params": [ "3emsAVdmGKERbHjmGfQ6oZ1e35dkf5iYcS6U4CPKFVaa" ] } ``` -------------------------------- ### Get Transaction Count with JavaScript Source: https://www.helius.dev/docs/rpc/guides/gettransactioncount Use the @solana/web3.js library to fetch the transaction count. This example shows how to get the count with the default commitment and with a specified 'confirmed' commitment. ```javascript const { Connection } = require('@solana/web3.js'); async function getCurrentTransactionCount() { // Replace with your RPC endpoint const connection = new Connection('https://mainnet.helius-rpc.com/?api-key='); try { const transactionCount = await connection.getTransactionCount(); console.log(`Current ledger transaction count: ${transactionCount}`); // Example with commitment const confirmedTransactionCount = await connection.getTransactionCount('confirmed'); console.log(`Current ledger transaction count (confirmed): ${confirmedTransactionCount}`); } catch (error) { console.error('Error fetching transaction count:', error); } } getCurrentTransactionCount(); ``` -------------------------------- ### Install Helius CLI and Sign Up Source: https://www.helius.dev/docs/agents/overview Install the Helius CLI, generate a keypair, fund the wallet, and obtain an API key with JSON output. Ensure the wallet is funded with 1 USDC and approximately 0.001 SOL. ```bash npm install -g helius-cli # Install CLI helius keygen # Generate keypair # Fund wallet with 1 USDC + ~0.001 SOL helius signup --json # Get API key (JSON output) ``` -------------------------------- ### Get All Known Cluster Nodes Source: https://www.helius.dev/docs/rpc/guides/getclusternodes This example fetches the list of all nodes known to the queried RPC endpoint. Use this to get a snapshot of the cluster's network topology. ```bash curl https://mainnet.helius-rpc.com/?api-key= -X POST -H "Content-Type: application/json" -d \ '{ "jsonrpc": "2.0", "id": 1, "method": "getClusterNodes" }' ``` -------------------------------- ### Setting Up a Webhook Listener Source: https://www.helius.dev/docs/api-reference/webhooks/llms.txt Example of an Express.js server to listen for and process incoming webhook notifications. ```APIDOC ## Setting Up a Webhook Listener ### Description This example demonstrates how to set up a basic webhook listener using Express.js to receive and process transaction data. ### Request Example ```javascript // Express.js server const express = require('express'); const app = express(); app.use(express.json()); app.post('/webhook', (req, res) => { const transactions = req.body; transactions.forEach(tx => { console.log(`New ${tx.type}: ${tx.description}`); // Process based on type if (tx.type === 'SWAP') { handleSwap(tx); } else if (tx.type === 'NFT_SALE') { handleNFTSale(tx); } else if (tx.type === 'TRANSFER') { handleTransfer(tx); } }); // Always return 200 to acknowledge receipt res.sendStatus(200); }); function handleSwap(tx) { const tokenIn = tx.tokenTransfers[0]; const tokenOut = tx.tokenTransfers[1]; console.log(`Swap: ${tokenIn.tokenAmount} รขโ€ โ€™ ${tokenOut.tokenAmount}`); // Store in database, trigger alerts, update UI, etc. } function handleNFTSale(tx) { const sale = tx.events.nft; console.log(`NFT sold for ${sale.amount / 1e9} SOL on ${tx.source}`); // Update marketplace, notify users, etc. } function handleTransfer(tx) { // Handle transfer logic } app.listen(3000, () => { console.log('Webhook listener running on port 3000'); }); ``` ``` -------------------------------- ### Get Signatures for Address Request Example Source: https://www.helius.dev/docs/api-reference/rpc/http/getsignaturesforaddress This example demonstrates a request to retrieve transaction signatures for a given address. It specifies the method, address, and a limit for the number of results. ```json { "jsonrpc": "2.0", "id": 1, "method": "getSignaturesForAddress", "params": [ "Vote111111111111111111111111111111111111111", { "limit": 1 } ] } ``` -------------------------------- ### Create and Initialize Project Source: https://www.helius.dev/docs/laserstream/grpc Set up a new project directory and initialize it with npm. This is the first step to begin using Helius LaserStream. ```bash mkdir laserstream-grpc-demo cd laserstream-grpc-demo npm init -y ``` -------------------------------- ### Helius API getSlot Request Example Source: https://www.helius.dev/docs/api-reference/rpc/http/getslot This is an example of a JSON-RPC request to the Helius API to get the current slot. Ensure you include your API key in the query parameters. ```json { "jsonrpc": "2.0", "id": "1", "method": "getSlot", "params": [ { "commitment": "finalized" } ] } ``` -------------------------------- ### Simulate Bundle Request Example Source: https://www.helius.dev/docs/api-reference/rpc/http/simulatebundle This example demonstrates how to structure a request to simulate a bundle of transactions. It includes parameters for encoded transactions, account configurations, signature verification, and simulation bank commitment. ```json { "jsonrpc": "2.0", "id": "1", "method": "simulateBundle", "params": [ { "encodedTransactions": [ "5rqF8aHfs9JyEtKTvND6z8RgBtYxQwZLndS1kzHxV7D3kWm9VoYRzFtsP3qra5bM8rGhC v82LYo8fZpQoyQmtN1D9vxG2uEsMhV7jB4KdADRgxMXn5kRJzLZPt2LrPSmcUhfEmeQa7X rKeR9FHdKcXxZ1Hdq68oBr2AaPpTMuL85KDCt", "5rqF8aHfs9JyEtKTvND6z8RgBtYxQwZLndS1kzHxV7D3kWm9VoYRzFtsP3qra5bM8rGhC v82LYo8fZpQoyQmtN1D9vxG2uEsMhV7jB4KdADRgxMXn5kRJzLZPt2LrPSmcUhfEmeQa7X rKeR9FHdKcXxZ1Hdq68oBr2AaPpTMuL85KDCt" ] }, { "preExecutionAccountsConfigs": [ { "addresses": [ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" ], "encoding": "base64" }, null ], "postExecutionAccountsConfigs": [ { "addresses": [ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" ], "encoding": "base64" }, null ], "skipSigVerify": true, "simulationBank": { "commitment": { "commitment": "processed" } }, "transactionEncoding": "base64", "replaceRecentBlockhash": false } ] } ``` -------------------------------- ### Initialize Go Project for gRPC Source: https://www.helius.dev/docs/grpc/quickstart Creates a new Go project directory and initializes the Go module. It then fetches the necessary Helius gRPC client and gRPC libraries. ```bash mkdir solana-grpc-stream cd solana-grpc-stream go mod init solana-grpc-stream go get github.com/rpcpool/yellowstone-grpc/examples/golang@latest go get google.golang.org/grpc@v1.67.1 ``` -------------------------------- ### Install Helius Claude Code Plugin Source: https://www.helius.dev/docs/agents/guides/personalized-swap-ui Install the Helius Claude Code plugin for Claude Code to utilize AI-assisted development features. This is a prerequisite for following the guide. ```bash /plugin marketplace add helius-labs/core-ai /plugin install helius@helius-labs ``` -------------------------------- ### Helius Rust SDK Quick Start Example Source: https://www.helius.dev/docs/agents/rust-sdk Initialize the Helius client and perform common operations like fetching NFTs by owner, retrieving transaction history, and sending transactions via Helius Sender. Requires an API key and a cluster configuration. ```rust use helius::error::Result; use helius::types::*; use helius::Helius; #[tokio::main] async fn main() -> Result<()> { let helius = Helius::new("YOUR_API_KEY", Cluster::MainnetBeta)?; // Get all NFTs owned by a wallet let assets = helius.rpc().get_assets_by_owner(GetAssetsByOwner { owner_address: "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY".to_string(), page: 1, limit: Some(50), ..Default::default() }).await?; // Get transaction history (with token account activity) let txs = helius.rpc().get_transactions_for_address( "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY".to_string(), GetTransactionsForAddressOptions { limit: Some(100), transaction_details: Some(TransactionDetails::Full), filters: Some(GetTransactionsFilters { token_accounts: Some(TokenAccountsFilter::BalanceChanged), ..Default::default() }), ..Default::default() }, ).await?; // Send a transaction via Helius Sender (ultra-low latency) let sig = helius.send_smart_transaction_with_sender( SmartTransactionConfig { create_config: CreateSmartTransactionConfig { instructions: vec![transfer_instruction], signers: vec![wallet_signer], ..Default::default() }, ..Default::default() }, SenderSendOptions { region: "US_EAST".to_string(), ..Default::default() }, ).await?; Ok(()) } ``` -------------------------------- ### Get Compressed Balance by Owner Request Example Source: https://www.helius.dev/docs/api-reference/zk-compression/llms.txt Use this to get the total lamport balance of all compressed accounts owned by a specific address. The owner's public key is required. ```javascript params: { owner: 'OWNER_PUBKEY' } ``` -------------------------------- ### Initialize Solana-py Client Source: https://www.helius.dev/docs/gatekeeper/migration-guide Create a Solana-py RPC client instance pointing to the Gatekeeper endpoint. The API key should be included in the URL. ```python from solana.rpc.api import Client rpc_url = f"https://beta.helius-rpc.com/?api-key={YOUR_API_KEY}" client = Client(rpc_url) ``` -------------------------------- ### Get Token Account Balance Response Example Source: https://www.helius.dev/docs/api-reference/rpc/http/gettokenaccountbalance Example JSON response for a successful `getTokenAccountBalance` request. It includes the token balance in raw amount, decimal places, and human-readable formats. ```json { "jsonrpc": "2.0", "id": "1", "result": { "context": { "slot": 1114 }, "value": { "amount": "9864", "decimals": 2, "uiAmount": 98.64, "uiAmountString": "98.64" } } } ``` -------------------------------- ### Get Limited Blocks from Start Slot (cURL) Source: https://www.helius.dev/docs/rpc/guides/getblockswithlimit Fetches a list of up to 5 confirmed block slots starting from slot 280000000. Ensure to replace with your actual API key. ```bash curl https://mainnet.helius-rpc.com/?api-key= -X POST -H "Content-Type: application/json" -d \ '{ "jsonrpc": "2.0", "id": 1, "method": "getBlocksWithLimit", "params": [ 280000000, 5 ] }' ``` -------------------------------- ### Set Up Rust Project for gRPC Source: https://www.helius.dev/docs/grpc/quickstart Initializes a new Rust project and lists the required dependencies in Cargo.toml for interacting with the Yellowstone gRPC service. ```bash cargo new solana-grpc-stream cd solana-grpc-stream ``` ```toml [dependencies] yellowstone-grpc-client = "1.13.0" yellowstone-grpc-proto = "1.13.0" tokio = { version = "1.0", features = ["full"] } anyhow = "1.0" utures = "0.3" tonic = "0.10" ``` -------------------------------- ### Get Blocks API Source: https://www.helius.dev/docs/api-reference/rpc/http/getblocks Retrieves a list of confirmed blocks between a specified start and end slot. ```APIDOC ## GET /blocks ### Description Returns a list of confirmed blocks between two slots. ### Method GET ### Endpoint /blocks ### Parameters #### Query Parameters - **slot** (number) - Required - Start slot. - **slot** (number) - Optional - End slot (must be โ‰ค 500,000 blocks from start slot). - **commitment** (string) - Optional - The commitment level for the request. Defaults to `finalized`. Possible values: `confirmed`, `finalized`. ### Request Example ```json { "slot": 123456789, "slot": 123457789, "commitment": "finalized" } ``` ### Response #### Success Response (200) - **blocks** (array) - An array of block objects. - **lastValidSlot** (number) - The last slot that was considered valid. #### Response Example ```json { "blocks": [ { "blockHeight": 123456789, "slot": 123456789, "timestamp": 1678886400, "transactions": [ { "transaction": { "signatures": ["sig1"], "message": { "recentBlockhash": "blockhash1" } }, "meta": { "fee": 5000, "logMessages": [], "postBalances": [], "postTokenBalances": [], "preBalances": [], "preTokenBalances": [], "rewards": [], "status": { "Ok": null } } } ] } ], "lastValidSlot": 123456789 } ``` ``` -------------------------------- ### Install Helius SDK and Solana Web3 Libraries Source: https://www.helius.dev/docs/staking/how-to-stake-with-helius-programmatically Install the necessary packages for interacting with the Solana blockchain and the Helius SDK. Choose the package manager that suits your project. ```bash npm install helius-sdk @solana/web3.js bs58 ``` ```bash yarn add helius-sdk @solana/web3.js bs58 ``` ```bash pnpm add helius-sdk @solana/web3.js bs58 ``` -------------------------------- ### Get Slot Leaders JSON-RPC Response Example Source: https://www.helius.dev/docs/rpc/guides/getslotleaders This is an example of the JSON-RPC response structure when requesting slot leaders. The 'result' field contains an array of base-58 encoded validator public keys. ```json { "jsonrpc": "2.0", "result": [ "ValidatorPubkey1XXXXXXXXXXXXXXXXXXXXXXXXXXXX", "ValidatorPubkey2XXXXXXXXXXXXXXXXXXXXXXXXXXXX", "ValidatorPubkey3XXXXXXXXXXXXXXXXXXXXXXXXXXXX" ], "id": 1 } ```