Wallet Creation and Trading

Create and manage Solana wallets programmatically, execute trades across multiple DEXs, and implement automated trading strategies with built-in safety mechanisms.

Wallet Management

Create and Import Wallets
import { HexaAI } from '@hexaai/sdk';

// Initialize the SDK
const hexa = new HexaAI('your_api_key');

// Create a new wallet
async function createWallet() {
  const wallet = await hexa.wallet.create({
    network: 'solana',
    encryption: 'aes-256-gcm',
    backupProvider: 'aws-kms' // optional cloud backup
  });
  
  console.log('New wallet created:', wallet.publicKey);
  return wallet;
}

// Import existing wallet
async function importWallet(privateKey) {
  const wallet = await hexa.wallet.import({
    network: 'solana',
    privateKey: privateKey,
    // Optional password encryption
    password: 'your-secure-password'
  });
  
  return wallet;
}

// Create multi-sig wallet
async function createMultiSig() {
  const multiSig = await hexa.wallet.createMultiSig({
    network: 'solana',
    requiredSignatures: 2,
    owners: [
      'pubkey1...',
      'pubkey2...',
      'pubkey3...'
    ]
  });
  
  return multiSig;
}

Trading Operations

Execute Trades
// Execute a market order
async function marketOrder(wallet) {
  const order = await hexa.trading.createOrder({
    wallet: wallet,
    market: 'SOL/USDC',
    side: 'buy',
    amount: 1.5,
    type: 'market',
    dex: 'jupiter'  // Uses Jupiter aggregator
  });
  
  console.log('Order executed:', order.signature);
  return order;
}

// Place a limit order
async function limitOrder(wallet) {
  const order = await hexa.trading.createOrder({
    wallet: wallet,
    market: 'SOL/USDC',
    side: 'buy',
    amount: 2.0,
    type: 'limit',
    price: 85.50,
    timeInForce: 'GTC'  // Good Till Cancelled
  });
  
  return order;
}

// Implement a simple DCA strategy
async function setupDCAStrategy(wallet) {
  const strategy = await hexa.trading.createStrategy({
    wallet: wallet,
    type: 'dca',
    config: {
      market: 'SOL/USDC',
      amount: 100,  // USDC per purchase
      interval: '1d',
      maxSlippage: 0.5
    }
  });
  
  return strategy;
}

Key Features

Secure Key Management

Enterprise-grade encryption for private keys with optional cloud backup support through AWS KMS or Azure Key Vault.

Smart Order Routing

Automatic order routing across multiple DEXs to find the best prices and lowest slippage for your trades.

Advanced Order Types

Support for market, limit, stop-loss, trailing-stop, and post-only orders with customizable parameters.

Trading Strategies

Built-in support for common trading strategies including DCA, grid trading, and custom strategy implementation.