The Helius Node.js library provides access to the Helius API from JavaScript/TypeScript.
API reference documentation is available at docs.helius.dev.
Using npm:
npm install helius-sdk
Using yarn:
yarn add helius-sdk
The package needs to be configured with your account's API key, which is available in the Helius Dashboard.
import { Helius } from 'helius-sdk';
// Replace YOUR_API_KEY with the API key from your Helius dashboard
const helius = new Helius('YOUR_API_KEY');
const getAssetsByOwner = async () => {
const response = await helius.rpc.getAssetsByOwner({
ownerAddress: '86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY',
page: 1,
});
console.log(response.items);
};
getAssetsByOwner();
When the API returns a non-success status code (4xx or 5xx response), an error message will be thrown:
try {
const response = await helius.rpc.getAssetsByOwner({
ownerAddress: '86xCnPeV69n6t3DnyGvkKobf9FdN2H9oiVDdaMpo2MMY',
page: 1,
});
console.log(response.items);
} catch (error) {
console.log(error);
}
When working with the Helius SDK, you may encounter several error codes. Below is a table detailing some of the common error codes along with additional information to help you troubleshoot:
Error Code | Error Message | More Information |
---|---|---|
401 | Unauthorized | This occurs when an invalid API key is provided or access is restricted due to RPC rules. |
429 | Too Many Requests | This indicates that the user has exceeded the request limit in a given timeframe or is out of credits. |
5XX | Internal Server Error | This is a generic error message for server-side issues. Please contact Helius support for assistance. |
If you encounter any of these errors, refer to the Helius documentation for further guidance, or reach out to the Helius support team for more detailed assistance.
Our SDK is designed to give you a seamless experience when building on Solana. We've separated the core functionality into various segments.
Comprehensive and performant API for tokens, NFTs, and compressed NFTs on Solana.
-
getAsset()
: Get an asset by its ID. -
getAssetBatch()
: Get multiple assets by ID (up to 1k). -
getSignaturesForAsset()
: Get a list of transaction signatures related to a compressed asset. -
searchAssets()
: Search for assets by a variety of parameters. Very useful for token-gating! -
getAssetProof()
: Get a Merkle proof for a compressed asset by its ID. -
getAssetsByOwner()
: Get a list of assets owned by an address. This is the fastest way to get all the NFTs and fungible tokens that are owned by a wallet on Solana. -
getAssetsByGroup()
: Get a list of assets by a group key and value. This endpoint is very useful for getting the mint list for NFT Collections. -
getAssetsByCreator()
: Get a list of assets created by an address. -
getAssetsByAuthority()
: Get a list of assets with a specific authority. -
getTokenAccounts()
: Get information about all token accounts for a specific mint or a specific owner. -
getNftEditions()
: Get information about all the edition NFTs for a specific master NFT
The easiest way to stake with Helius programmatically.
-
createStakeTransaction()
: Generate a transaction to create + delegate a new stake account to the Helius validator. -
createUnstakeTransaction()
: Generate a transaction to deactivate a stake account. -
createWithdrawTransaction()
: Generate a transaction to withdraw lamports from a stake account (after cooldown). -
getStakeInstructions()
: Return only the instructions for creating and delegating a stake account. -
getUnstakeInstruction()
: Return the instruction to deactivate a stake account. -
getWithdrawInstruction()
: Return the instruction to withdraw lamports from a stake account. -
getWithdrawableAmount()
: Determine how many lamports are withdrawable (with optional rent-exempt inclusion). -
getHeliusStakeAccounts()
: Return all stake accounts delegated to the Helius validator for a given wallet.
The easiest way to mint compressed NFTs at scale.
Note, this API has been deprecated and the relevant methods will be removed in a future release. Please refer to ZK Compression for all future compression-related work
-
mintCompressedNft()
: Mint a new compressed NFT. -
delegateCollectionAuthority()
: Delegates collection authority to a new address. -
revokeCollectionAuthority()
: Revokes collection authority from an address. -
getMintlist()
Get all the tokens for an NFT collection.
Provides methods for setting up, editing, and managing webhooks, crucial for listening to on-chain Solana events (e.g., sales, listings, swaps) and triggering actions when these events happen.
-
createWebhook()
: Creates a new webhook with the provided request. -
editWebhook()
: Edits an existing webhook by its ID with the provided request. -
appendAddressesToWebhook()
: Append new addresses to an existing webhook. -
removeAddressesFromWebhook()
: Remove addresses from an existing webhook. -
deleteWebhook()
: Deletes a webhook by its ID. -
getWebhookByID()
: Retrieves a single webhook by its ID. -
getAllWebhooks()
: Retrieves a list of all webhooks. -
createCollectionWebhook()
Create a new collection webhook with the provided request.
-
createSmartTransaction()
: Creates a smart transaction with the provided configuration -
getComputeUnits()
: Simulates a transaction to get the total compute units consumed -
pollTransactionConfirmation()
: Polls a transaction to check whether it has been confirmed -
sendSmartTransaction()
: Builds and sends an optimized transaction
Jito Smart Transactions and Helper Methods
-
addTipInstruction()
: Adds a tip instruction as the last instruction given the provided instructions -
createSmartTransactionWithTip()
: Creates a smart transaction with a Jito tip -
getBundleStatuses()
: Gets the status of the provided bundles -
sendJitoBundle()
: Sends a bundle of transactions to the Jito Block Engine -
sendSmartTransactionWithTip()
: Sends a smart transaction as a Jito bundle with a tip
Offers additional tools for various Solana-related tasks like analyzing blockchain throughput and tracking stake accounts and SPL token holders.
-
getCurrentTPS()
: Returns the current transactions per second (TPS) rate — including voting transactions. -
airdrop()
: Request an allocation of lamports to the specified address -
getStakeAccounts()
: Returns all the stake accounts for a given public key. -
getTokenHolders()
: Returns all the token accounts for a given mint address (ONLY FOR SPL TOKENS). -
getPriorityFeeEstimate()
: Returns an estimated priority fee based on a set of predefined priority levels (percentiles). -
sendTransaction()
: Wrapper forsendTransaction
RPC call that includes support forvalidatorAcls
parameter. -
executeJupiterSwap()
: Execute a token swap using Jupiter Exchange with automatic transaction optimizations including priority fees, compute unit calculation, and reliable transaction confirmation.