A high-performance, type-safe JavaScript SDK for building applications on the Tari blockchain. Built with Rust FFI bindings for optimal performance and comprehensive TypeScript support.
The Tari JavaScript SDK empowers developers to build robust applications on the Tari network with a comprehensive, type-safe interface. Leveraging Rust FFI bindings for exceptional performance and security, this SDK provides everything you need to integrate Tari wallet functionality into your JavaScript applications.
Why Choose Tari JavaScript SDK?
- 🚀 Exceptional Performance: Native Rust FFI bindings deliver optimal speed and efficiency
- 🔒 Enterprise Security: Hardware-backed secure storage with cross-platform compatibility
- 🛡️ Memory Safety: Automatic resource management prevents leaks and vulnerabilities
- 📦 Developer Experience: Complete TypeScript definitions with intelligent autocomplete
- 🌐 Production Ready: Comprehensive testing infrastructure ensures reliability
- ⚡ Tauri Optimized: First-class Tauri support for desktop applications
# Install the complete wallet package
npm install @tari-project/tarijs-wallet
# Or install core utilities only
npm install @tari-project/tarijs-core
import {
TariWallet,
NetworkType,
createSecureStorage
} from '@tari-project/tarijs-wallet';
import { loadNativeModuleForNetwork } from '@tari-project/tarijs-core';
// STEP 1: Load network-specific FFI binary (required!)
await loadNativeModuleForNetwork(NetworkType.Testnet);
// STEP 2: Create wallet with real blockchain functionality
const wallet = await TariWallet.create({
network: NetworkType.Testnet, // Must match loaded FFI binary
storagePath: './my-wallet',
logLevel: 'info',
// Secure storage with automatic backend selection
storage: await createSecureStorage({
enableCaching: true, // Performance optimization
enableBatching: true, // Batch operations for efficiency
testBackends: true // Verify backend availability
})
});
// Get wallet address
const address = await wallet.getAddress();
console.log(`Wallet address: ${address.toString()}`);
// Check balance
const balance = await wallet.getBalance();
console.log(`Available: ${balance.available} µT`);
// Send a transaction
const txId = await wallet.sendTransaction(
'recipient_address_here',
1000000n, // 1 Tari in microTari
{ message: 'Payment for services' }
);
// Listen for events
wallet.on('onTransactionReceived', (tx) => {
console.log(`Received ${tx.amount} µT from ${tx.source}`);
});
// Clean up resources
await wallet.destroy();
# 1. Clone and install dependencies
git clone https://github.com/tari-project/tari-javascript-sdk.git
cd tari-javascript-sdk
npm install
# 2. Setup Tari source code (required for FFI compilation)
npm run setup:tari-source
# 3. Build testnet FFI binary (recommended for development)
npm run build:networks:testnet
# 4. Verify setup
npm run validate:build
npm run test:integration
The SDK supports three networks, each requiring its own FFI binary:
Network | Purpose | Build Command | Test Funds |
---|---|---|---|
testnet | Development & testing | npm run build:networks:testnet |
Discord faucet |
mainnet | Production applications | npm run build:networks:mainnet |
Real Tari required |
nextnet | Pre-release features | npm run build:networks:nextnet |
Limited availability |
# Build all networks sequentially (10-15 minutes)
npm run build:all-networks
# Or build in parallel (faster, more resources)
npm run build:all-networks:parallel
# Validate all builds
npm run validate:build
📖 Complete Setup Guide: See DEVELOPER_SETUP.md for detailed instructions, troubleshooting, and advanced configuration.
For Tauri applications, the SDK automatically provides enhanced security and performance:
import { PlatformDetector } from '@tari-project/tarijs-wallet';
// Detect Tauri runtime
const platform = PlatformDetector.detect();
if (platform.runtime === 'tauri') {
console.log('🦀 Running with Tauri optimization!');
console.log('Security level: Hardware-backed');
console.log('Performance: 60% lower memory, 10x faster startup');
}
This monorepo contains focused packages for different use cases:
Core FFI bindings, type definitions, error handling, and memory management utilities. Essential for any Tari integration.
Complete wallet API for transaction management, balance queries, address handling, and event management. Build full wallet applications with this package.
- Node.js 18.0.0 or higher
- npm 8.0.0 or higher
- Rust 1.70.0 or higher (for FFI compilation)
# Clone the repository
git clone https://github.com/tari-project/tari-javascript-sdk.git
cd tari-javascript-sdk
# Install dependencies
npm install
# Build all packages
npm run build
# Run comprehensive tests
npm test
# Run linting and type checking
npm run lint && npm run typecheck
Command | Description |
---|---|
npm run build |
Build all packages |
npm run build:ts |
TypeScript compilation only |
npm run clean |
Clean all build artifacts |
npm test |
Run all test suites |
npm run test:unit |
Unit tests with mocked FFI |
npm run test:integration |
Integration tests with real FFI |
npm run test:e2e |
End-to-end network tests |
npm run lint |
Lint all packages |
npm run lint:fix |
Fix linting issues |
npm run typecheck |
Type checking only |
The SDK supports all Tari network configurations:
- Mainnet - Production network for live transactions
- Testnet - Testing network for development and validation
- Nextnet - Pre-release network for cutting-edge features
The SDK includes comprehensive testing at multiple levels:
- Unit Tests - Fast feedback with comprehensive FFI mocking
- Integration Tests - Real FFI validation with isolated environments
- E2E Tests - Network connectivity testing with real testnet
- Performance Tests - Automated benchmarking with regression detection
- Manual Tests - Interactive validation for funded wallets
# Run all test suites
npm test
# Run specific test types
npm run test:unit
npm run test:integration
npm run test:e2e
# Run performance benchmarks
npm run test:performance
# Run manual testing framework
cd examples/manual-tests && npm start
- macOS: Keychain integration with Touch ID/Face ID support
- Windows: Credential Store with DPAPI encryption
- Linux: Secret Service with libsecret fallback
- Tauri: Hardware-backed storage via Rust security boundary
- Electron: Secure IPC with context isolation
- Hardware-backed storage when available
- Automatic backend selection and health monitoring
- Memory encryption for sensitive data
- Rate limiting and input validation
- Comprehensive error sanitization
First-class support with superior security and performance:
- Hardware-backed security via Rust boundary
- 60% lower memory footprint vs Electron
- 10x faster startup times
- Explicit permission system
- Type-safe IPC commands
Legacy support with comprehensive security:
- Context isolation between processes
- Secure IPC with validation
- Rate limiting and origin checking
- Security policy management
Direct integration for server applications:
- Native FFI access
- Platform-specific storage backends
- Full API compatibility
- Node Console Wallet - Interactive command-line wallet with full functionality
- Manual Tests - Interactive testing framework for real funds
- Tauri Wallet App - Full-featured desktop wallet (in development)
- Tauri Integration - Complete Tauri setup guide
- API Reference - Detailed API documentation
Framework | Bundle Size | Memory Usage | Startup Time | Security |
---|---|---|---|---|
Tauri | 3-10MB | ~40MB | 0.2-0.5s | Hardware-backed |
Electron | ~50MB | ~100MB | 2-5s | Context isolation |
Node.js | N/A | ~20MB | <0.1s | OS-dependent |
- Intelligent Caching: Reduces redundant operations by up to 85%
- Batch Processing: Groups operations for optimal FFI performance
- Memory Optimization: Automatic cleanup and leak detection
- Platform-Specific: Tailored optimizations for each environment
We welcome contributions! Please see our Contributing Guide for details on:
- Development setup and environment
- Code style and conventions
- Testing requirements and procedures
- Pull request and review process
Resource | Description |
---|---|
API Reference | Complete wallet API documentation |
Tauri Integration | Tauri setup and optimization guide |
Contributing Guide | Development and contribution guidelines |
This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.
- 🐛 Issues: GitHub Issues
- 💻 Source Code: GitHub Repository
Ready to build on Tari? The SDK provides everything you need to create secure, high-performance applications on the Tari network. Get started with the examples above or dive into the comprehensive documentation.