Skip to content

About

A comprehensive TypeScript utility library for Stellar blockchain development

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Stellar Toolkit 🌟

CI Status Version License

A comprehensive TypeScript/JavaScript utility library that simplifies common Stellar blockchain operations. Built for developers who want clean, tested, and production-ready helpers for Stellar development.

Documentation site: Stellar Toolkit guide

Current Version: v0.1.0

🎯 Overview

Stellar Toolkit provides high-level abstractions over the Stellar SDK, making it easier to:

  • Create and manage accounts
  • Send payments and handle assets
  • Interact with the Stellar network
  • Parse and format Stellar data
  • Handle common error scenarios gracefully

πŸš€ Features

  • Account Management: Simplified account creation, funding, and balance checking
  • Payment Operations: Easy-to-use payment and path payment functions
  • Asset Utilities: Create, manage, and query custom assets
  • Network Helpers: Automatic network detection and configuration
  • Error Handling: Comprehensive error handling with meaningful messages
  • Type-Safe: Full TypeScript support with detailed type definitions
  • Well Tested: Comprehensive test suite with example tests
  • CI/CD: Automated testing and linting on every commit

πŸ“¦ Installation

npm install @hyperdevtools/stellar-toolkit
# or
yarn add @hyperdevtools/stellar-toolkit
# or
pnpm add @hyperdevtools/stellar-toolkit

πŸ”§ Quick Start

import { StellarToolkit } from '@hyperdevtools/stellar-toolkit';

// Initialize the toolkit
const toolkit = new StellarToolkit({
  network: 'testnet', // or 'mainnet'
});

// Create a new account
const keypair = toolkit.generateKeypair();
console.log('New account:', keypair.publicKey);

// Send a payment
await toolkit.sendPayment({
  from: sourceSecret,
  to: destinationPublicKey,
  amount: '10',
  asset: 'native',
});

πŸ“š Documentation

Account Operations

// Create a new keypair
const keypair = toolkit.generateKeypair();

// Get account details
const account = await toolkit.getAccount(publicKey);

// Get account balances
const balances = await toolkit.getBalances(publicKey);

// Fund a testnet account
await toolkit.fundTestnetAccount(publicKey);

Payment Operations

// Simple payment
await toolkit.sendPayment({
  from: sourceSecret,
  to: destinationPublicKey,
  amount: '100',
  asset: 'native',
  memo: 'Payment for services',
});

// Custom asset payment
await toolkit.sendPayment({
  from: sourceSecret,
  to: destinationPublicKey,
  amount: '50',
  asset: {
    code: 'USDC',
    issuer: 'GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5',
  },
});

// Path payment
await toolkit.sendPathPayment({
  from: sourceSecret,
  to: destinationPublicKey,
  sendAsset: 'native',
  destAsset: { code: 'USDC', issuer: '...' },
  destAmount: '100',
  maxSend: '110',
});

Asset Operations

// Create a custom asset
const asset = toolkit.createAsset('MYTOKEN', issuerPublicKey);

// Establish trustline
await toolkit.addTrustline({
  account: accountSecret,
  asset: {
    code: 'USDC',
    issuer: 'GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5',
  },
  limit: '10000',
});

Multi-Signature Account Operations

// Configure a 2-of-3 multi-signature account
await toolkit.configureMultiSig({
  masterSecret,
  masterWeight: 1,
  signers: [
    { publicKey: signer2PublicKey, weight: 1 },
    { publicKey: signer3PublicKey, weight: 1 },
  ],
  thresholds: { low: 1, medium: 2, high: 2 },
});

// Sign a transaction with multiple signers and verify threshold
const signedTx = toolkit.signMultiSigTransaction(tx, [masterSecret, signer2Secret], 2);

Path Payment Strict Send

// Send exact source amount (100 XLM) with automatic Horizon path discovery and slippage protection
await toolkit.sendPathPaymentStrictSend({
  from: sourceSecret,
  to: destinationPublicKey,
  sendAsset: 'native',
  sendAmount: '100',
  destAsset: {
    code: 'USDC',
    issuer: 'GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5',
  },
  minDestAmount: '95',
});

Fee Bump Transactions

// Bump the fee on an existing v1 transaction
const bumpedHash = await toolkit.submitFeeBumpTransaction({
  feeSourceSecret: sponsorSecret,
  innerTransaction: stuckTransactionXdr,
  maxFeePerOp: 500,
});

Claimable Balances & AMM Liquidity Pools

// Create a time-locked claimable balance
await toolkit.createClaimableBalance({
  from: senderSecret,
  asset: 'native',
  amount: '100',
  claimants: [
    {
      destination: recipientPublicKey,
      predicate: { type: 'not_before', unixTimestamp: Math.floor(Date.now() / 1000) + 3600 },
    },
  ],
});

// Deposit liquidity into a constant-product AMM pool
await toolkit.depositLiquidity({
  accountSecret: userSecret,
  assetA: 'native',
  assetB: {
    code: 'USDC',
    issuer: 'GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5',
  },
  maxAmountA: '200',
  maxAmountB: '50',
  minPrice: '3.8',
  maxPrice: '4.2',
});

πŸ§ͺ Development

Build Scripts

# Build the project
./scripts/build.sh

# Run tests
./scripts/test.sh

# Run linter
./scripts/lint.sh

Or using npm:

npm test          # Run test suite
npm run build     # Build for production
npm run lint      # Check code style

Testing

The project includes a comprehensive test suite:

npm test                  # Run all tests
npm test -- --watch       # Run tests in watch mode
npm test -- --coverage    # Run with coverage report

🀝 Contributing

We welcome contributions! Please see our CONTRIBUTING.md for details.

Good First Issues: Check out issues labeled good-first-issue

Development Setup

# Clone the repository
git clone https://github.com/HyperDevTools/stellar-toolkit.git
cd stellar-toolkit

# Install dependencies
npm install

# Run tests
npm test

# Build the project
npm run build

CI/CD

All pull requests are automatically tested with:

  • βœ… Unit tests (Jest)
  • βœ… ESLint checks
  • βœ… TypeScript compilation
  • βœ… Code formatting (Prettier)
  • βœ… Multi-version testing (Node 18.x, 20.x)

See .github/workflows/ci.yml for details.

πŸ“‹ Roadmap

See CHANGELOG.md for version history.

Planned Features:

  • Multi-signature account support
  • Path payment strict send operations
  • Claimable balance helpers
  • Liquidity pool operations
  • DEX trading utilities
  • Fee bump transaction helpers
  • Batch operation support
  • Enhanced error recovery

πŸ“š API Documentation

Detailed API documentation available in docs/api/:

πŸ“„ License

MIT License - see LICENSE for details

πŸ™ Acknowledgments

Built with:

πŸ”— Links

πŸ’¬ Support

🌟 Show Your Support

If you find this project useful, please:

  • ⭐ Star the repository
  • πŸ› Report bugs and suggest features
  • 🀝 Contribute code or documentation
  • πŸ“’ Share with other developers

Part of the HyperDevTools organization β€’ Building developer tools for the Stellar ecosystem

About

A comprehensive TypeScript utility library for Stellar blockchain development

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages