Skip to content

Avalanche SDK TypeScript provides a complete set of tools and libraries for developers to interact with the Avalanche blockchain ecosystem.

License

Notifications You must be signed in to change notification settings

ava-labs/avalanche-sdk-typescript

Avalanche SDK

Avalanche SDK Typescript

The official TypeScript SDK suite for building on Avalanche

License: BSD-3-Clause Node Version TypeScript

Overview

Avalanche SDK for TypeScript is a modular suite for building on the Avalanche ecosystem. It covers:

  • Direct chain access (RPC, wallets, transactions)
  • Indexed data + metrics (Glacier Data API & Metrics API)
  • Interchain messaging (ICM/Teleporter for cross–L1 apps)

This monorepo includes multiple specialized SDKs, each designed for specific use cases while maintaining consistency and interoperability.

⚠️ Developer Preview: This suite of SDKs is currently in beta and is subject to change. We'd love to hear about your experience! Please share your feedback here. Use in production at your own risk.

Which SDK Should I Use?

SDK Description
@avalanche-sdk/client Direct blockchain interaction - transactions, wallets, RPC calls
@avalanche-sdk/chainkit Complete suite: Data, Metrics and Webhooks API
@avalanche-sdk/interchain Send messages between Avalanche L1s using ICM/Teleporter

Available SDKs

The main Avalanche client SDK for interacting with Avalanche nodes and building blockchain applications.

Features:

  • Complete API coverage for P-Chain, X-Chain, and C-Chain
  • Full viem compatibility - anything you can do with viem works here
  • TypeScript-first design with full type safety
  • Abstractions over the JSON-RPC API to make your life easier
  • Wallet integration and transaction management
  • First-class APIs for interacting with Smart Contracts
  • Retrieve balances and UTXOs for addresses
  • Build, sign, and issue transactions to any chain
  • Perform cross-chain transfers between X, P and C chains
  • Add validators and delegators
  • Create subnets and blockchains, convert subnets to L1s

Combined SDK with full typed coverage of Avalanche Data (Glacier) and Metrics APIs.

Features:

  • Full endpoint coverage for Glacier Data API and Metrics API
  • Strongly-typed models, pagination helpers, and automatic retries/backoff
  • High-level helpers for transactions, blocks, addresses, tokens, NFTs, and logs
  • Metrics: network health, validator stats, throughput, latency, and block production analytics
  • Webhooks-compatible payload shapes and utilities for signature verification
  • Configurable base URL and API key authentication
  • Request logging and middleware hooks for observability

SDK for building cross-L1 applications and bridges.

Features:

  • Type-safe ICM client for sending cross-chain messages
  • Works seamlessly with wallet clients
  • Built-in support for Avalanche C-Chain and custom subnets

Getting Started

Prerequisites

  • Node.js 20+
  • npm, yarn, or pnpm
  • TypeScript 5.0+ (recommended)

Installation

Install SDKs

# Install only what you need
npm install @avalanche-sdk/client        # Core RPC functionality
npm install @avalanche-sdk/interchain    # Cross-chain messaging
npm install @avalanche-sdk/chainkit      # Indexed data, metrics, and webhooks

Quick Examples

Client: Get AVAX Balance

import { createAvalancheClient } from '@avalanche-sdk/client'
import { avalanche } from '@avalanche-sdk/client/chains'

const client = createAvalancheClient({
  chain: avalanche,
  transport: {
    type: "http"
  }
})

// Get account balance
const balance = await client.getBalance({ 
  address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
})

View more Client SDK examples →

ChainKit: Get ERC20 balances

import { Avalanche } from "@avalanche-sdk/chainkit";

const avalanche = new Avalanche({
  chainId: "43114",
});

async function run() {
  const result = await avalanche.data.evm.address.balances.listErc20({
    address: "0x8ae323046633A07FB162043f28Cea39FFc23B50A",
  });
  console.log(JSON.stringify(result, null, 2));
}

run();

View more ChainKit SDK examples →

Interchain: Send cross-chain message

import { createWalletClient, http } from "viem";
import { createICMClient } from "@avalanche-sdk/interchain";
import { privateKeyToAccount } from "viem/accounts";
import * as dotenv from 'dotenv';

// Load environment variables
dotenv.config();

// these will be made available in a separate SDK soon
import { avalancheFuji, dispatch } from "@avalanche-sdk/interchain/chains";

// Get private key from environment
const privateKey = process.env.PRIVATE_KEY;
if (!privateKey) {
  throw new Error("PRIVATE_KEY not found in environment variables");
}

// Load your signer/account
const account = privateKeyToAccount(privateKey as `0x${string}`);

// Create a viem wallet client connected to Avalanche Fuji
const wallet = createWalletClient({
  transport: http('https://api.avax-test.network/ext/bc/C/rpc'),
  account,
});

// Initialize the ICM client
const icmClient = createICMClient(wallet);

// Send a message across chains
async function main() {
  try {
    const hash = await icmClient.sendMsg({
      sourceChain: avalancheFuji,
      destinationChain: dispatch,
      message: 'Hello from Avalanche Fuji to Dispatch Fuji!',
    });
    console.log('Message sent with hash:', hash);
  } catch (error) {
    console.error('Error sending message:', error);
    process.exit(1);
  }
}

main();

View more Interchain SDK examples →

What You Can Build

Blockchain Infrastructure

  • Custom RPC endpoints and API gateways
  • Transaction broadcasting services
  • Multi-chain wallet backends
  • Account management systems

Data Analytics & Monitoring

  • Portfolio tracking applications
  • Transaction history explorers
  • Token balance dashboards
  • Network health monitoring tools
  • Validator performance trackers

Real-Time Applications

  • Price alert systems
  • Transaction notification services
  • Smart contract event monitors
  • Blockchain activity feeds

Cross-Chain Communication

  • ICM message relayers
  • Cross-L1 notification systems
  • Interchain data synchronization
  • Multi-chain coordination tools

Developer Tools

  • Smart contract debugging interfaces
  • Transaction simulation tools
  • Network testing utilities
  • Blockchain data indexers

Documentation

Each SDK includes comprehensive documentation:

Examples

Each SDK includes practical examples demonstrating common use cases:

Architecture

The Avalanche SDK TypeScript suite is designed with modularity in mind:

avalanche-sdk-typescript/
├── client/          # Main client SDK
├── chainkit/        # Development tools
└── interchain/      # Cross-chain SDK

Each SDK is:

  • Independent - Can be used standalone
  • Modular - Import only what you need
  • Type-safe - Full TypeScript support
  • Well-documented - Comprehensive guides and examples

Performance & Best Practices

Optimization Tips

  • Use the unified SDK for better tree-shaking when using multiple features
  • Enable request batching for bulk operations
  • Implement proper error handling and retries
  • Cache frequently accessed data
  • Use WebSocket connections for real-time data

Security Considerations

  • Never expose private keys in client-side code
  • Use environment variables for sensitive data
  • Validate all inputs before blockchain interactions
  • Implement proper access controls
  • Follow security best practices

Troubleshooting

Common Issues

Issue Solution
Module not found errors Ensure you're using Node.js 20+ and have installed dependencies
TypeScript errors Update to TypeScript 5.0+ and check tsconfig.json
Connection timeouts Check network settings and RPC endpoint availability
Transaction failures Verify gas settings and account balance
Type mismatches Ensure all SDKs are on compatible versions

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Quick Start for Contributors

# Clone the repository
git clone https://github.com/ava-labs/avalanche-sdk-typescript.git
cd avalanche-sdk-typescript

# Move to the SDK directory you want to work on
cd client

# Install dependencies
npm install

# Run tests
npm test

# Build all packages
npm run build

Looking for Good First Issues?

Check out our good first issues to get started!

Support

Documentation & Resources

Community & Help

Issue Tracking

Direct Support

Release Notes

See CHANGELOG.md for a detailed version history.

License

This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.


Built with ❤️ by the Avalanche Team

WebsiteDocumentationBlogGitHub

About

Avalanche SDK TypeScript provides a complete set of tools and libraries for developers to interact with the Avalanche blockchain ecosystem.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages