# Integration

## Overview

This document outlines the technical approach for integrating with Multiplier's wagering infrastructure. The integration will enable native token payouts and secure game outcome processing for partner gaming experiences.

## Integration Architecture

### Core Concept

* **Branded Gaming Experiences**: Partners can create custom gaming experiences with their own branding
* **Native Token Wagering**: Players wager and receive payouts in specified tokens
* **Solana Support**: Integration supports Solana ecosystems
* **Security Mechanisms**: Holding periods and anti-manipulation safeguards

## Technical Implementation

### Backend Integration Flow

#### Step 1: Game Initialization

```javascript
Partner Game Client → Multiplier Backend
SubmitFn(gameInputs) → {attemptId, signature, cookie}
```

* Partner submits game parameters and player inputs to Multiplier's backend
* Multiplier validates inputs and returns attempt tracking data
* The `signature` ensures game integrity and prevents manipulation

#### Step 2: Blockchain Transaction

```javascript
Partner Client → Smart Contract
submitBet(attemptId, signature, betAmount, tokenAddress)
```

* Partner calls the appropriate smart contract
* Bet amount processed in specified token
* Transaction is linked to the specific game attempt

#### Step 3: Result Processing

```typescript
Partner Client → Multiplier Backend
getStatus(attemptId) → gameResult
```

* Retrieve current game outcome using the attempt ID
* Result contains win/loss status and payout calculations (if finalized)
* Backend uses `ResultFn(gameInputs, seed) => result` internally

### Extended Flow for Progressive Games

#### Additional Step: State Updates

```typescript
Partner Client → Multiplier Backend
updateStatus(attemptId, cookie, transitionInfo)
```

* Allows real-time game state updates until completion
* Enables progressive jackpots, multi-round games, and interactive experiences
* Cookie ensures only authorized updates

## Smart Contract Integration

### Blockchain Support

* **Solana**: Support for SOL and SPL tokens output. SOL and sMINT for input
* **Token Flexibility**: Each integration can specify supported token contracts

### Security Mechanisms

* **Holding Periods**: Configurable lock periods for winnings
* **Staking Integration**: Optional staking rewards for held tokens
* **Gradual Release**: Implement vesting schedules for large payouts

## Data Types and Contracts

### Game Input Interface

```typescript
interface GameInputs {
  playerId: string;
  gameType: string;
  betAmount: number;
  tokenContract: string;
  partnerIntegrationId: string;
  gameParameters: object;
}
```

### Game Result Interface

```typescript
interface GameResult {
  attemptId: string;
  status: 'pending' | 'completed' | 'failed';
  isWin: boolean;
  payoutAmount: number;
  tokenContract: string;
  holdingPeriod?: number;
}
```

## Key Considerations

### Security

* All game logic executed on Multiplier's backend to prevent client-side manipulation
* Cryptographic signatures ensure game integrity
* Partner authentication and rate limiting

### Scalability

* Backend designed to handle high-frequency gaming transactions
* Batch processing for multiple simultaneous games
* Efficient state management for progressive games

### User Experience

* Seamless integration within partner's existing game interface
* Real-time status updates for pending games
* Clear indication of holding periods and token lock status

### Partner Onboarding

* API key management and authentication setup
* Integration testing environment
* Documentation and SDK availability

### Monitoring and Analytics

* Transaction tracking and reporting
* Game outcome verification
* Performance metrics and uptime monitoring


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.multiplier.fun/for-developers/integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
