helius-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.5.0 • Public • Published

Helius Node.js SDK

Version Downloads

The Helius Node.js library provides access to the Helius API from JavaScript/TypeScript.

Documentation

API reference documentation is available at docs.helius.dev.

Installation

Using npm:

npm install helius-sdk

Using yarn:

yarn add helius-sdk

Usage

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();

Try it out

Handling errors

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);
}

Common Error Codes

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.

Using the Helius SDK

Our SDK is designed to give you a seamless experience when building on Solana. We've separated the core functionality into various segments.

DAS API

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

Staking

The easiest way to stake with Helius programmatically.

Mint API

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

Webhooks

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.

Smart Transactions

Jito Smart Transactions and Helper Methods

Helper Methods

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 for sendTransaction RPC call that includes support for validatorAcls parameter.
  • executeJupiterSwap(): Execute a token swap using Jupiter Exchange with automatic transaction optimizations including priority fees, compute unit calculation, and reliable transaction confirmation.

Package Sidebar

Install

npm i helius-sdk

Weekly Downloads

8,890

Version

1.5.0

License

ISC

Unpacked Size

318 kB

Total Files

115

Last publish

Collaborators

  • heliuslabs