npm package: @hqlinhmmo/super-smart-sdk
Description: Super Smart Web3 SDK for blockchain gaming and pool management
Author: Super Smart Team
Latest version: 1.0.0

# Super Smart Web3 SDK

A comprehensive TypeScript SDK for building blockchain-based gaming applications with pool management, Worldcoin integration, and smart contract interactions.

## Features

- 🎮 **Gaming Pool Management**: Create and manage gaming pools with customizable parameters
- 🔐 **Worldcoin Integration**: Seamless authentication and verification using Worldcoin MiniKit
- 🎫 **Ticket System**: Mint and manage gaming tickets with ERC721 tokens
- 🏆 **Reward Distribution**: Automated reward calculation and distribution
- 📱 **Client SDK**: Easy-to-use client-side SDK for frontend applications
- 🔧 **Server SDK**: Full-featured server-side SDK for backend operations

## Installation

```bash
npm install @super-smart/web3-sdk
```

## Quick Start

### Client SDK (Frontend)

```typescript
import { SuperSmartClientSDK } from "@super-smart/web3-sdk";

const clientSDK = new SuperSmartClientSDK({
  isProduction: false, // Set to true for mainnet
  superSmartContractAddress: "0x...", // Your contract address
  miniappId: "your-miniapp-id",
});

// Login with Worldcoin
const { commandPayload, finalPayload, nonce } = await clientSDK.login();

// Get user info
const userInfo = await clientSDK.getUserInfo();

// Join a game pool
const poolId = BigInt(1);
const ticketPrice = await clientSDK.getJoinPoolTicketPrice(poolId);
const receipt = await clientSDK.joinGame(poolId, ticketPrice);
```

### Server SDK (Backend)

```typescript
import SuperSmartSDK from "@super-smart/web3-sdk";

const serverSDK = new SuperSmartSDK({
  isProduction: false,
  superSmartContractAddress: "0x...",
  miniappId: "your-miniapp-id",
  privateKey: "your-private-key", // Required for server operations
});

// Create a new pool
await serverSDK.openPool({
  startTime: Math.floor(Date.now() / 1000) + 3600, // 1 hour from now
  endTime: Math.floor(Date.now() / 1000) + 7200, // 2 hours from now
  ticketPrice: BigInt(1000000000000000000), // 1 ETH in wei
  fee: 500, // 5% fee (500 basis points)
  rewardStructure: [5000, 3000, 2000], // Winner gets 50%, 2nd gets 30%, 3rd gets 20%
});

// Finish a game
await serverSDK.finishGame({
  poolId: BigInt(1),
  player: "0x...",
  startTime: Math.floor(Date.now() / 1000),
  endTime: Math.floor(Date.now() / 1000) + 3600,
  correctAnswer: "correct-answer",
  score: 95,
});
```

## API Reference

### SuperSmartClientSDK

#### Constructor

```typescript
new SuperSmartClientSDK({
  isProduction: boolean;
  superSmartContractAddress: string;
  miniappId: string;
})
```

#### Methods

- `login()`: Authenticate with Worldcoin and return login payload
- `getUserInfo()`: Get current user information
- `getUserBalance()`: Get user's token balance
- `joinGame(poolId: bigint, ticketPrice: bigint)`: Join a gaming pool
- `getJoinPoolTicketPrice(poolId: bigint)`: Get ticket price for a pool
- `getUnclaimedRewards()`: Get user's unclaimed rewards

### SuperSmartSDK

#### Constructor

```typescript
new SuperSmartSDK({
  isProduction: boolean;
  superSmartContractAddress: string;
  miniappId: string;
  privateKey?: string;
})
```

#### Methods

- `verifyLogin(payload, nonce)`: Verify Worldcoin login
- `openPool(params)`: Create a new gaming pool
- `closePool(poolId: bigint)`: Close an existing pool
- `verifyJoinPool(poolId: bigint, userAddress: string)`: Check if user joined pool
- `finishGame(params)`: Complete a game and distribute rewards
- `mintTickets(to: string, amount: bigint)`: Mint tickets for a user

## Configuration

### Environment Variables

```bash
# Required for server operations
PRIVATE_KEY=your-private-key

# Optional: Custom RPC URLs
RPC_URL_MAINNET=https://mainnet.infura.io/v3/your-key
RPC_URL_TESTNET=https://sepolia.infura.io/v3/your-key
```

### Network Configuration

The SDK supports both mainnet and testnet configurations:

- **Mainnet**: Ethereum mainnet with production settings
- **Testnet**: Sepolia testnet for development and testing

## Requirements

- Node.js >= 18.0.0
- TypeScript >= 5.0.0
- Modern browser with Web3 support

## Dependencies

- `@worldcoin/minikit-js`: Worldcoin authentication
- `viem`: Ethereum interaction library
- `ethers`: Ethereum utilities
- `axios`: HTTP client

## License

MIT

## Support

For support and questions, please open an issue on our [GitHub repository](https://github.com/your-org/super-smart/issues).

## Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests to our [GitHub repository](https://github.com/your-org/super-smart).