# Splitwise Solana Client SDK

A TypeScript/JavaScript client SDK for interacting with the Splitwise Solana Settlement program.

## Installation

```bash
npm install splitwise-solana-client
```

## Usage

```typescript
import { SplitSettlementSDK } from 'splitwise-solana-client';
import { Connection, Keypair } from '@solana/web3.js';

// Initialize the SDK
const connection = new Connection('https://api.devnet.solana.com');
const wallet = Keypair.generate(); // Or use your own wallet
const sdk = new SplitSettlementSDK({
  connection,
  wallet,
  oracleEndpoint: 'http://localhost:3001',
  oracleApiKey: 'your-api-key'
});

// Create a settlement
const settlement = await sdk.createSettlement({
  splitwiseId: '123',
  amount: 100,
  from: fromPubkey,
  to: toPubkey,
  tokenMint: tokenMintPubkey,
  minPaymentAmount: 10,
  expiryTimestamp: Date.now() + 86400000 // 24 hours
});

// Monitor settlement updates
sdk.on('settlementUpdate', (event) => {
  console.log('Settlement updated:', event);
});

// Make a payment
await sdk.makePayment(settlement.publicKey, 50);
```

## Features

- Create and manage settlements
- Make payments
- Monitor settlement status changes
- Real-time updates via WebSocket subscriptions
- Built-in error handling and validation

## Requirements

- Node.js 16+
- Solana wallet (e.g., Phantom, Solflare)
- Access to Solana network (Mainnet, Devnet, or local)
- Oracle service API key

## License

MIT 