### Install Helius TypeScript SDK Source: https://context7.com/helius-labs/helius-sdk/llms.txt Install the SDK using your preferred package manager. Peer dependencies must be installed separately. ```shell pnpm add helius-sdk # or npm install helius-sdk # or yarn add helius-sdk ``` ```shell pnpm add @solana/kit @solana-program/system @solana-program/token \ @solana-program/compute-budget @solana-program/stake ``` -------------------------------- ### Get Project Usage Statistics Source: https://context7.com/helius-labs/helius-sdk/llms.txt Returns current billing-period credit usage, remaining credits, and per-product usage breakdown for a project. The API key must belong to the same project as the `projectId` requested. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const usage = await helius.admin.getProjectUsage("YOUR_PROJECT_UUID"); console.log("Credits used:", usage.creditsUsed); console.log("Credits remaining:", usage.creditsRemaining); console.log("Plan:", usage.subscriptionDetails.plan); console.log( "Billing cycle:", usage.subscriptionDetails.billingCycle.start, "→", usage.subscriptionDetails.billingCycle.end ); console.log("RPC usage:", usage.usage.rpc); console.log("DAS usage:", usage.usage.das); console.log("Webhook usage:", usage.usage.webhook); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Get Program Accounts V2 with Pagination and Filters Source: https://context7.com/helius-labs/helius-sdk/llms.txt An enhanced `getProgramAccounts` with cursor-based pagination and `changedSinceSlot` support. Use `paginationKey` for subsequent pages and `changedSinceSlot` for incremental syncs. Filters like `dataSize` and `memcmp` can be applied. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); const TOKEN_PROGRAM = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; try { // First page with size filter const page1 = await helius.getProgramAccountsV2([ TOKEN_PROGRAM, { encoding: "jsonParsed", limit: 100, filters: [{ dataSize: 165 }] }, ]); console.log("Accounts:", page1.accounts.length); // Next page via paginationKey if (page1.paginationKey) { const page2 = await helius.getProgramAccountsV2([ TOKEN_PROGRAM, { encoding: "jsonParsed", limit: 100, paginationKey: page1.paginationKey }, ]); console.log("More accounts:", page2.accounts.length); } // Incremental updates since a specific slot const changed = await helius.getProgramAccountsV2([ TOKEN_PROGRAM, { encoding: "base64", limit: 50, changedSinceSlot: 363340000 }, ]); console.log("Changed accounts:", changed.accounts.length); // Memcmp filter for a specific owner const owner = "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY"; const owned = await helius.getProgramAccountsV2([ TOKEN_PROGRAM, { encoding: "base64", limit: 20, filters: [ { dataSize: 165 }, { memcmp: { offset: 32, bytes: owner } }, ], }, ]); console.log("Owned token accounts:", owned.accounts.length); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Get All Program Accounts (Auto-Paginated) Source: https://context7.com/helius-labs/helius-sdk/llms.txt Auto-paginates through all pages of `getProgramAccountsV2` to return every account in a single array. Use with caution on large programs due to potential memory and performance implications. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const allAccounts = await helius.getAllProgramAccounts([ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", { encoding: "base64", filters: [{ dataSize: 165 }] }, ]); console.log("Total program accounts:", allAccounts.length); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Get Asset Merkle Proofs Source: https://context7.com/helius-labs/helius-sdk/llms.txt Retrieves Merkle proofs for compressed NFTs (cNFTs) to verify them on-chain. Supports fetching single proofs or batch proofs for multiple assets. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { // Single proof const proof = await helius.getAssetProof({ id: "Bu1DEKeawy7txbnCEJE4BU3BKLXaNAKCYcHR4XhndGss", }); console.log("Root:", proof.root); console.log("Proof depth:", proof.proof?.length); // Batch proofs const batchProofs = await helius.getAssetProofBatch({ ids: [ "Bu1DEKeawy7txbnCEJE4BU3BKLXaNAKCYcHR4XhndGss", "81bxPqYCE8j34nQm7Rooqi8Vt3iMHLzgZJ71rUVbQQuz", ], }); console.log("Batch proofs:", Object.keys(batchProofs).length); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### helius.getTokenAccounts() Source: https://context7.com/helius-labs/helius-sdk/llms.txt Gets token account information by owner or by mint address, with cursor-based pagination. ```APIDOC ## getTokenAccounts() ### Description Gets token account information by owner or by mint address, with cursor-based pagination. ### Method Signature `helius.getTokenAccounts({ owner?: string, mint?: string, limit?: number, after?: string })` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **owner** (string) - Optional - The wallet address of the token account owner. - **mint** (string) - Optional - The mint address of the token. - **limit** (number) - Optional - The number of token accounts to return per page (default is 10). - **after** (string) - Optional - A cursor for fetching the next page of results. ### Request Example ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const result = await helius.getTokenAccounts({ owner: "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY", limit: 10, // after: "UGWUWf8HZscd6AnEsUnCXMVteXtvqdKuZD45YzWej8w", // cursor for next page }); console.log("Token accounts:", result.token_accounts?.length); } catch (error) { console.error("Error:", error); } ``` ### Response #### Success Response (200) - **token_accounts** (array) - An array of token account objects. #### Response Example ```json { "token_accounts": [ { "account": "token_account_address_1", "mint": "mint_address_1", "owner": "owner_address", "amount": "100", "decimals": 6 // ... other token account properties } ] } ``` ``` -------------------------------- ### Get Assets by Owner Address (DAS API) Source: https://context7.com/helius-labs/helius-sdk/llms.txt Retrieve all fungible tokens and NFTs owned by a specific wallet address. Supports pagination and sorting. Requires an API key. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const result = await helius.getAssetsByOwner({ ownerAddress: "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY", page: 1, limit: 50, sortBy: { sortBy: "created", sortDirection: "asc" }, }); console.log("Total assets:", result.total); result.items.forEach((a) => console.log(a.id, a.interface)); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Get Wallet Funding Source Source: https://context7.com/helius-labs/helius-sdk/llms.txt Discovers the original funding source for a wallet, including the funder's identity if it is a known entity. Requires an API key and the wallet address. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const info = await helius.wallet.getFundedBy({ wallet: "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY", }); console.log("Funder:", info.funder); console.log("Funder name:", info.funderName ?? "private wallet"); console.log("Amount:", info.amount, info.symbol); console.log("Date:", info.date); console.log("Explorer:", info.explorerUrl); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Get Token Accounts by Owner Source: https://context7.com/helius-labs/helius-sdk/llms.txt Retrieves token account information for a given owner address. Supports cursor-based pagination. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const result = await helius.getTokenAccounts({ owner: "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY", limit: 10, // after: "UGWUWf8HZscd6AnEsUnCXMVteXtvqdKuZD45YzWej8w", // cursor for next page }); console.log("Token accounts:", result.token_accounts?.length); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Estimate Compute Units with getComputeUnits Source: https://context7.com/helius-labs/helius-sdk/llms.txt Simulates a transaction to estimate its compute unit consumption before sending. Requires API key and signer setup. Useful for optimizing transaction fees and avoiding C.U. limits. ```typescript import { createHelius } from "helius-sdk"; import { createKeyPairSignerFromBytes, lamports, address } from "@solana/kit"; import { getTransferSolInstruction } from "@solana-program/system"; import bs58 from "bs58"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); const signer = await createKeyPairSignerFromBytes( bs58.decode(process.env.FEEPAYER_SECRET ?? "") ); const ix = getTransferSolInstruction({ amount: lamports(1_000_000n), destination: address("RECIPIENT_ADDRESS"), source: signer, }); try { const units = await helius.tx.getComputeUnits({ signers: [signer], instructions: [ix], version: 0, }); console.log("Estimated CUs:", units); // e.g. 450 } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Get Token Accounts by Owner V2 with Pagination Source: https://context7.com/helius-labs/helius-sdk/llms.txt An enhanced, cursor-paginated version of `getTokenAccountsByOwner` that supports `changedSinceSlot` for incremental syncing. Use the `paginationKey` for fetching subsequent pages. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const page1 = await helius.getTokenAccountsByOwnerV2([ "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY", { mint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", limit: 10 }, ]); console.log("Token accounts:", page1.accounts.length); console.log("Next cursor:", page1.paginationKey); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Get Priority Fee Estimate for Transaction Source: https://context7.com/helius-labs/helius-sdk/llms.txt Returns priority fee estimates at various percentile levels to help balance landing speed and cost. Requires account keys and optional configuration. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const estimate = await helius.getPriorityFeeEstimate({ accountKeys: ["JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"], options: { includeAllPriorityFeeLevels: true }, }); console.log("Min fee:", estimate.priorityFeeLevels?.min); console.log("Medium fee:", estimate.priorityFeeLevels?.medium); console.log("High fee:", estimate.priorityFeeLevels?.high); console.log("Very high fee:", estimate.priorityFeeLevels?.veryHigh); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Get Signatures for Compressed NFT (cNFT) Source: https://context7.com/helius-labs/helius-sdk/llms.txt Retrieves the chronological transaction history for a compressed NFT. Ensure you have a valid API key and the correct asset ID. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const sigs = await helius.getSignaturesForAsset({ id: "Bu1DEKeawy7txbnCEJE4BU3BKLXaNAKCYcHR4XhndGss", page: 1, limit: 10, }); console.log("Total transactions:", sigs.total); sigs.items.forEach(([sig, type]) => console.log(sig, type)); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Get Wallet Balances - Helius SDK Source: https://context7.com/helius-labs/helius-sdk/llms.txt Retrieve all token and NFT balances for a wallet, including USD valuations and pagination support. Set `showNative` to true to include SOL balance and `showNfts` to true for NFTs. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const balances = await helius.wallet.getBalances({ wallet: "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY", showNative: true, // include SOL balance showNfts: false, // set true to include NFTs page: 1, limit: 100, }); console.log(`Total USD value: $${balances.totalUsdValue.toFixed(2)}`); balances.balances.forEach((token) => { console.log(`${token.symbol}: ${token.balance} ($${token.usdValue?.toFixed(2) ?? "n/a"})`); }); console.log("Has more pages:", balances.pagination.hasMore); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Get ZK Validity Proof - Helius SDK Source: https://context7.com/helius-labs/helius-sdk/llms.txt Use this to obtain a ZK proof for verifying compressed accounts and new address creation with the Light Protocol compression program. Ensure you have the correct API key. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const proof = await helius.zk.getValidityProof({ hashes: ["12dAzsyUjd6riPCGCzrbHt1pupXiQD9UCetFiUesYzfn"], // newAddresses: ["..."], // optional: prove new addresses are unclaimed }); console.log(JSON.stringify(proof, null, 2)); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Get Compressed Token Balances by Owner V2 - Helius SDK Source: https://context7.com/helius-labs/helius-sdk/llms.txt Fetches aggregated token balances for a wallet's compressed token accounts. V2 addresses a minor naming inconsistency from V1. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const balances = await helius.zk.getCompressedTokenBalancesByOwnerV2({ owner: "YOUR_WALLET_ADDRESS", }); balances.items.forEach((b) => { console.log("Mint:", b.mint, "Balance:", b.balance); }); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### List Stake Accounts and Get Withdrawable Amounts Source: https://context7.com/helius-labs/helius-sdk/llms.txt Retrieves all stake accounts delegated to the Helius validator for a given wallet and queries their withdrawable lamport balances. You can choose to include or exclude rent-exempt reserves in the withdrawable amount calculation. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const stakeAccounts = await helius.stake.getHeliusStakeAccounts( "YOUR_WALLET_ADDRESS" ); for (const acc of stakeAccounts) { const pubkey = acc.pubkey.toString(); const withdrawableExRent = await helius.stake.getWithdrawableAmount(pubkey); const withdrawableInclRent = await helius.stake.getWithdrawableAmount( pubkey, true // include rent-exempt reserve ); console.log(`Stake account: ${pubkey}`); console.log(` Withdrawable (ex-rent): ${withdrawableExRent} lamports`); console.log(` Withdrawable (incl-rent): ${withdrawableInclRent} lamports`); } } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Manage webhooks with helius.webhooks.getAll(), get(), update(), delete(), toggle() Source: https://context7.com/helius-labs/helius-sdk/llms.txt Provides full CRUD operations for managing webhooks. The toggle() method is useful for re-enabling or pausing webhooks without deletion. Ensure you have the correct webhook ID for these operations. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { // List all webhooks const all = await helius.webhooks.getAll(); console.log("Total webhooks:", all.length); // Get a specific webhook const wh = await helius.webhooks.get("WEBHOOK_ID"); console.log("Status:", wh.active); // Update a webhook const updated = await helius.webhooks.update("WEBHOOK_ID", { webhookURL: "https://your-server.com/new-endpoint", accountAddresses: ["NEW_WATCH_ADDRESS"], transactionTypes: ["TRANSFER"], webhookType: "enhanced", }); console.log("Updated:", updated.webhookID); // Re-enable an auto-disabled webhook const toggled = await helius.webhooks.toggle("WEBHOOK_ID", true); console.log("Now active:", toggled.active); // Delete a webhook const deleted = await helius.webhooks.delete("WEBHOOK_ID"); console.log("Deleted:", deleted); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Initialize Helius SDK Client Source: https://context7.com/helius-labs/helius-sdk/llms.txt Create the main `HeliusClient` using `createHelius`. An API key is required for certain services. Sub-clients are lazily initialized. ```typescript import { createHelius } from "helius-sdk"; // Mainnet with API key const helius = createHelius({ apiKey: "YOUR_API_KEY" }); // Devnet const heliusDev = createHelius({ apiKey: "YOUR_API_KEY", network: "devnet" }); // Custom RPC endpoint const heliusCustom = createHelius({ apiKey: "YOUR_API_KEY", baseUrl: "https://mainnet.helius-rpc.com/", rebateAddress: "YOUR_WALLET_ADDRESS", userAgent: "myapp/1.0", }); // Standard Solana RPC methods work directly on the client const { value: blockhash } = await helius.getLatestBlockhash(); console.log("Blockhash:", blockhash); const balance = await helius.getBalance("So11111111111111111111111111111111111111112"); const slot = await helius.getSlot(); ``` -------------------------------- ### createHelius(options) Source: https://context7.com/helius-labs/helius-sdk/llms.txt Initializes the main HeliusClient. All sub-clients are lazily initialized on first access. Accepts an optional apiKey, network, rebateAddress, baseUrl, and userAgent string. ```APIDOC ## createHelius(options) — Initialize the SDK client ### Description Creates the main `HeliusClient`. All sub-clients are lazily initialized on first access. Accepts an optional `apiKey` (required for webhooks, enhanced transactions, wallet API, and admin API), a `network` (`"mainnet"` or `"devnet"`, default `"mainnet"`), a `rebateAddress` for RPC credit rebates, a custom `baseUrl`, and a custom `userAgent` string. ### Usage ```typescript import { createHelius } from "helius-sdk"; // Mainnet with API key const helius = createHelius({ apiKey: "YOUR_API_KEY" }); // Devnet const heliusDev = createHelius({ apiKey: "YOUR_API_KEY", network: "devnet" }); // Custom RPC endpoint const heliusCustom = createHelius({ apiKey: "YOUR_API_KEY", baseUrl: "https://mainnet.helius-rpc.com/", rebateAddress: "YOUR_WALLET_ADDRESS", userAgent: "myapp/1.0", }); // Standard Solana RPC methods work directly on the client const { value: blockhash } = await helius.getLatestBlockhash(); console.log("Blockhash:", blockhash); const balance = await helius.getBalance("So11111111111111111111111111111111111111112"); const slot = await helius.getSlot(); ``` ``` -------------------------------- ### Get Transactions by Address Source: https://context7.com/helius-labs/helius-sdk/llms.txt Retrieves a paginated history of enriched transactions associated with a specific wallet address, providing decoded data for each transaction. ```APIDOC ## Enhanced Transactions — `helius.enhanced.getTransactionsByAddress()` Retrieves a rich, paginated transaction history for a wallet address with human-readable decoded data for every transaction. ### Parameters #### Request Body - **address** (string) - Required - The Solana wallet address to retrieve transaction history for. - **limit** (number) - Optional - The maximum number of transactions to return per page. Defaults to 10. ### Request Example ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const history = await helius.enhanced.getTransactionsByAddress({ address: "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY", limit: 10, }); history.forEach((tx) => { console.log(tx.signature, tx.type, tx.source); }); } catch (error) { console.error("Error:", error); } ``` ### Response #### Success Response (200) - Returns an array of enriched transaction objects for the specified address. ``` -------------------------------- ### Get Enhanced Transactions Source: https://context7.com/helius-labs/helius-sdk/llms.txt Retrieves enriched transaction data for a given list of transaction signatures. This provides human-readable details, decoded instructions, and metadata. ```APIDOC ## Enhanced Transactions — `helius.enhanced.getTransactions()` Converts raw Solana transaction signatures into human-readable, enriched transaction objects with decoded instruction data, token transfers, and contextual metadata. ### Parameters #### Request Body - **transactions** (array) - Required - An array of transaction signatures (strings). - **commitment** (string) - Optional - The commitment level for fetching transaction data (e.g., "confirmed", "finalized"). ### Request Example ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const txns = await helius.enhanced.getTransactions({ transactions: [ "4jZNT882jBCSReECrssxVHaLKV5RPxuGSFUDhoJmzj6AbPBfHakFsTC27HBfGVE7rPsCbcBjUeZPNUDmm3U218Rg", ], commitment: "confirmed", }); txns.forEach((tx) => { console.log("Type:", tx.type); console.log("Source:", tx.source); console.log("Fee:", tx.fee); tx.tokenTransfers?.forEach((t) console.log(` ${t.tokenAmount} of ${t.mint}`) ); }); } catch (error) { console.error("Error:", error); } ``` ### Response #### Success Response (200) - Returns an array of enriched transaction objects. Each object may contain fields like `type`, `source`, `fee`, and `tokenTransfers`. ``` -------------------------------- ### helius.getAssetProof() / helius.getAssetProofBatch() Source: https://context7.com/helius-labs/helius-sdk/llms.txt Returns the Merkle proof(s) needed to verify and interact with compressed NFTs (cNFTs) on-chain. ```APIDOC ## getAssetProof() / getAssetProofBatch() ### Description Returns the Merkle proof(s) needed to verify and interact with compressed NFTs (cNFTs) on-chain. ### Method Signature `helius.getAssetProof({ id: string })` `helius.getAssetProofBatch({ ids: string[] })` ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - **id** (string) - Required (for `getAssetProof`) - The asset ID of the compressed NFT. - **ids** (string[]) - Required (for `getAssetProofBatch`) - An array of asset IDs for compressed NFTs. ### Request Example ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { // Single proof const proof = await helius.getAssetProof({ id: "Bu1DEKeawy7txbnCEJE4BU3BKLXaNAKCYcHR4XhndGss", }); console.log("Root:", proof.root); console.log("Proof depth:", proof.proof?.length); // Batch proofs const batchProofs = await helius.getAssetProofBatch({ ids: [ "Bu1DEKeawy7txbnCEJE4BU3BKLXaNAKCYcHR4XhndGss", "81bxPqYCE8j34nQm7Rooqi8Vt3iMHLzgZJ71rUVbQQuz", ], }); console.log("Batch proofs:", Object.keys(batchProofs).length); } catch (error) { console.error("Error:", error); } ``` ### Response #### Success Response (200) - **root** (string) - The Merkle root. - **proof** (array) - An array of proof hashes (for `getAssetProof`). - **batchProofs** (object) - An object where keys are asset IDs and values are proof objects (for `getAssetProofBatch`). #### Response Example ```json { "root": "merkle_root_hash", "proof": [ "proof_hash_1", "proof_hash_2" ] } ``` ```json { "Bu1DEKeawy7txbnCEJE4BU3BKLXaNAKCYcHR4XhndGss": { "root": "merkle_root_hash_1", "proof": ["proof_hash_1a", "proof_hash_1b"] }, "81bxPqYCE8j34nQm7Rooqi8Vt3iMHLzgZJ71rUVbQQuz": { "root": "merkle_root_hash_2", "proof": ["proof_hash_2a", "proof_hash_2b"] } } ``` ``` -------------------------------- ### Get NFT Print Editions Source: https://context7.com/helius-labs/helius-sdk/llms.txt Returns all print editions for a given master-edition NFT, including their serial numbers and owners. Requires an API key. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const editions = await helius.getNftEditions({ mint: "Ey2Qb8kLctbchQsMnhZs5DjY32To2QtPuXNwWvk4NosL", }); console.log("Total editions:", editions.total); editions.items?.forEach((e) => console.log("Edition:", e.edition_number, "Owner:", e.owner)); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### auth.agenticSignup() Source: https://context7.com/helius-labs/helius-sdk/llms.txt Enables AI agents to programmatically create a Helius account, sign up, and obtain an API key by paying 1 USDC. ```APIDOC ## makeAuthClient() → auth.agenticSignup() ### Description Enables AI agents to programmatically create a Helius account, sign up, and obtain an API key by paying 1 USDC. Handles wallet generation, balance checks, project creation, and payment in one call. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **secretKey** (Uint8Array) - Required - The secret key of the wallet to use for signup. ### Request Example ```typescript import { makeAuthClient } from "helius-sdk/auth/client"; import { createHelius } from "helius-sdk"; (async () => { const auth = makeAuthClient(); // Step 1: Generate (or load) a wallet keypair const { secretKey } = await auth.generateKeypair(); // Alternative: const keypair = auth.loadKeypair(savedSecretKeyUint8Array); // Step 2: Full agentic signup — creates project and pays if needed const result = await auth.agenticSignup({ secretKey }); console.log("Status:", result.status); // "success" | "existing_project" console.log("Wallet:", result.walletAddress); console.log("Project ID:", result.projectId); console.log("API Key:", result.apiKey); console.log("Credits:", result.credits); if (result.txSignature) { console.log("Payment TX:", result.txSignature); } // Step 3: Use the returned API key immediately if (result.apiKey) { const helius = createHelius({ apiKey: result.apiKey }); const slot = await helius.getSlot(); console.log("Current slot:", slot); } })(); ``` ### Response #### Success Response (200) - **status** (string) - The status of the signup process. Possible values: "success" or "existing_project". - **walletAddress** (string) - The newly created or existing wallet address. - **projectId** (string) - The UUID of the Helius project. - **apiKey** (string) - The API key for the new project. - **credits** (number) - The number of credits granted. - **txSignature** (string) - The transaction signature for the payment, if applicable. #### Response Example ```json { "status": "success", "walletAddress": "newWalletAddress", "projectId": "projectUUID", "apiKey": "newApiKey", "credits": 10000, "txSignature": "paymentTxSignature" } ``` ``` -------------------------------- ### Get Compression Signatures for Owner - Helius SDK Source: https://context7.com/helius-labs/helius-sdk/llms.txt Returns transaction signatures that have modified any of an owner's compressed accounts. Useful for auditing or tracking activity. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const sigs = await helius.zk.getCompressionSignaturesForOwner({ owner: "YOUR_WALLET_ADDRESS", }); sigs.items.forEach((item) => console.log(item.signature)); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### V2 RPC Methods — helius.getAllProgramAccounts() Source: https://context7.com/helius-labs/helius-sdk/llms.txt Auto-paginates through all pages of `getProgramAccountsV2` and returns every account in one array. Use with caution on large programs. ```APIDOC ## getAllProgramAccounts() ### Description Auto-paginates through all pages of `getProgramAccountsV2` and returns every account in one array. Use with caution on large programs. ### Method POST ### Endpoint /v0/mainnet-beta/get-program-accounts ### Parameters #### Path Parameters - **programId** (string) - Required - The program ID to query. #### Request Body - **encoding** (string) - Optional - The encoding for the account data (e.g., "base64", "jsonParsed"). - **filters** (array) - Optional - An array of filters to apply to the accounts. - **dataSize** (number) - Optional - Filters accounts by data size. - **memcmp** (object) - Optional - Filters accounts by memory comparison. - **offset** (number) - Required - The offset in bytes to start comparing. - **bytes** (string) - Required - The byte string to compare against. ### Request Example ```json [ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", { "encoding": "base64", "filters": [{ "dataSize": 165 }] } ] ``` ### Response #### Success Response (200) - **accounts** (array) - An array of all program accounts. - **[pubkey, account]** (array) - Each item contains the account's public key (string) and account data (object). #### Response Example ```json { "accounts": [ ["accountPubKey1", { "data": {...}, "executable": false, "lamports": 1000 }] ] } ``` ``` -------------------------------- ### Get transactions by address with helius.enhanced.getTransactionsByAddress() Source: https://context7.com/helius-labs/helius-sdk/llms.txt Retrieves a paginated history of transactions for a given wallet address with decoded data. Ideal for displaying a user's transaction history. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const history = await helius.enhanced.getTransactionsByAddress({ address: "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY", limit: 10, }); history.forEach((tx) => { console.log(tx.signature, tx.type, tx.source); }); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### V2 RPC Methods — helius.getProgramAccountsV2() Source: https://context7.com/helius-labs/helius-sdk/llms.txt An enhanced version of `getProgramAccounts` with cursor-based pagination and `changedSinceSlot` support for efficient, incremental sync of large program account sets. ```APIDOC ## getProgramAccountsV2() ### Description An enhanced version of `getProgramAccounts` with cursor-based pagination and `changedSinceSlot` support for efficient, incremental sync of large program account sets. ### Method POST ### Endpoint /v0/mainnet-beta/get-program-accounts ### Parameters #### Path Parameters - **programId** (string) - Required - The program ID to query. #### Request Body - **encoding** (string) - Optional - The encoding for the account data (e.g., "base64", "jsonParsed"). - **limit** (number) - Optional - The maximum number of accounts to return per page. - **filters** (array) - Optional - An array of filters to apply to the accounts. - **dataSize** (number) - Optional - Filters accounts by data size. - **memcmp** (object) - Optional - Filters accounts by memory comparison. - **offset** (number) - Required - The offset in bytes to start comparing. - **bytes** (string) - Required - The byte string to compare against. - **paginationKey** (string) - Optional - A cursor for fetching the next page of results. - **changedSinceSlot** (number) - Optional - Fetches accounts that have changed since the specified slot. ### Request Example ```json [ "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA", { "encoding": "jsonParsed", "limit": 100, "filters": [ { "dataSize": 165 }, { "memcmp": { "offset": 32, "bytes": "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY" } } ], "paginationKey": "someCursor" } ] ``` ### Response #### Success Response (200) - **accounts** (array) - An array of program accounts. - **[pubkey, account]** (array) - Each item contains the account's public key (string) and account data (object). - **paginationKey** (string) - Optional - A cursor for fetching the next page of results. #### Response Example ```json { "accounts": [ ["accountPubKey1", { "data": {...}, "executable": false, "lamports": 1000 }] ], "paginationKey": "nextCursor" } ``` ``` -------------------------------- ### Fetch Assets by Creator Address Source: https://context7.com/helius-labs/helius-sdk/llms.txt Lists all assets created by a specific creator address. Optionally filter for verified creators only. Supports pagination. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const assets = await helius.getAssetsByCreator({ creatorAddress: "D3XrkNZz6wx6cofot7Zohsf2KSsu2ArngNk8VqU9bTEk", onlyVerified: true, page: 1, limit: 20, }); console.log("Assets created:", assets.total); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### helius.admin.getProjectUsage() Source: https://context7.com/helius-labs/helius-sdk/llms.txt Returns current billing-period credit usage, remaining credits, and per-product usage breakdown for a project. ```APIDOC ## helius.admin.getProjectUsage() ### Description Returns current billing-period credit usage, remaining credits, and per-product usage breakdown for a project. The API key must belong to the same project as the `projectId` requested. ### Parameters #### Path Parameters None #### Query Parameters - **projectId** (string) - Required - The UUID of the project to get usage for. ### Request Example ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const usage = await helius.admin.getProjectUsage("YOUR_PROJECT_UUID"); console.log("Credits used:", usage.creditsUsed); console.log("Credits remaining:", usage.creditsRemaining); console.log("Plan:", usage.subscriptionDetails.plan); console.log("Billing cycle:", usage.subscriptionDetails.billingCycle.start, "→", usage.subscriptionDetails.billingCycle.end); console.log("RPC usage:", usage.usage.rpc); console.log("DAS usage:", usage.usage.das); console.log("Webhook usage:", usage.usage.webhook); } catch (error) { console.error("Error:", error); } ``` ### Response #### Success Response (200) - **creditsUsed** (number) - The number of credits used in the current billing period. - **creditsRemaining** (number) - The number of credits remaining in the current billing period. - **subscriptionDetails** (Object) - **plan** (string) - The current subscription plan. - **billingCycle** (Object) - **start** (string) - The start date of the billing cycle. - **end** (string) - The end date of the billing cycle. - **usage** (Object) - **rpc** (number) - Usage of the RPC service. - **das** (number) - Usage of the DAS service. - **webhook** (number) - Usage of the webhook service. #### Response Example ```json { "creditsUsed": 1000, "creditsRemaining": 9000, "subscriptionDetails": { "plan": "free", "billingCycle": { "start": "2023-01-01T00:00:00Z", "end": "2023-02-01T00:00:00Z" } }, "usage": { "rpc": 500, "das": 300, "webhook": 200 } } ``` ``` -------------------------------- ### Create Webhook Source: https://context7.com/helius-labs/helius-sdk/llms.txt Creates a new webhook that triggers on specified on-chain events. You can define the target URL, event types, and accounts to monitor. ```APIDOC ## Webhooks — `helius.webhooks.create()` Creates a new webhook that calls your HTTPS endpoint whenever on-chain events match the specified account addresses and transaction types. ### Parameters #### Request Body - **webhookURL** (string) - Required - The HTTPS URL to send webhook notifications to. - **transactionTypes** (array) - Required - An array of transaction types to listen for (e.g., "TRANSFER", "NFT_SALE", "SWAP"). - **accountAddresses** (array) - Required - An array of Solana account addresses to monitor. - **webhookType** (string) - Optional - The type of webhook. Can be "enhanced", "raw", or "discord". Defaults to "enhanced". ### Request Example ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const webhook = await helius.webhooks.create({ webhookURL: "https://your-server.com/webhook", transactionTypes: ["TRANSFER", "NFT_SALE", "SWAP"], accountAddresses: ["YOUR_WATCH_ADDRESS"], webhookType: "enhanced", // "enhanced" | "raw" | "discord" }); console.log("Webhook ID:", webhook.webhookID); console.log("Active:", webhook.active); } catch (error) { console.error("Error:", error); } ``` ### Response #### Success Response (200) - **webhookID** (string) - The unique identifier for the created webhook. - **active** (boolean) - Indicates if the webhook is currently active. ``` -------------------------------- ### Get Wallet Transaction History Source: https://context7.com/helius-labs/helius-sdk/llms.txt Retrieves paginated transaction history with balance changes for a wallet. Requires an API key and specifies wallet address, page number, and limit. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const history = await helius.wallet.getHistory({ wallet: "86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY", page: 1, limit: 20, }); history.history.forEach((tx) => { console.log(tx.signature, tx.type); }); console.log("Has more:", history.pagination.hasMore); } catch (error) { console.error("Error:", error); } ``` -------------------------------- ### Get enhanced transactions with helius.enhanced.getTransactions() Source: https://context7.com/helius-labs/helius-sdk/llms.txt Converts raw Solana transaction signatures into human-readable objects. Useful for analyzing specific transactions with details like decoded instructions and token transfers. ```typescript import { createHelius } from "helius-sdk"; const helius = createHelius({ apiKey: "YOUR_API_KEY" }); try { const txns = await helius.enhanced.getTransactions({ transactions: [ "4jZNT882jBCSReECrssxVHaLKV5RPxuGSFUDhoJmzj6AbPBfHakFsTC27HBfGVE7rPsCbcBjUeZPNUDmm3U218Rg", ], commitment: "confirmed", }); txns.forEach((tx) => { console.log("Type:", tx.type); console.log("Source:", tx.source); console.log("Fee:", tx.fee); tx.tokenTransfers?.forEach((t) console.log(` ${t.tokenAmount} of ${t.mint}`) ); }); } catch (error) { console.error("Error:", error); } ```