puul_partner_sdk 1.5.3 copy "puul_partner_sdk: ^1.5.3" to clipboard
puul_partner_sdk: ^1.5.3 copied to clipboard

Official Dart/Flutter SDK for the Puul Partner API — integrate prediction markets and lottery draws into your mobile app.

example/puul_partner_sdk_example.dart

/// Example: Using the Puul Partner SDK to list markets and place a prediction.
///
/// This example demonstrates the core workflow:
/// 1. Initialize the SDK with your credentials
/// 2. List available prediction markets
/// 3. Place a prediction on a market outcome
library;

import 'package:puul_partner_sdk/puul_partner_sdk.dart';

Future<void> main() async {
  // Initialize the SDK with your partner credentials
  final puul = PuulPartner(
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret',
  );

  try {
    // List all live prediction markets
    final markets = await puul.markets.list();
    print('Found ${markets.length} live markets');

    if (markets.isEmpty) {
      print('No live markets available');
      return;
    }

    // Display first market details
    final market = markets.first;
    print('Market: ${market.question}');
    print('Outcomes: ${market.outcomes.length}');

    for (final outcome in market.outcomes) {
      print('  - ${outcome.label} (pool: ${outcome.poolAmount})');
    }

    // Link a user before placing predictions
    final linkToken = await puul.sessions.createLinkToken(
      externalUserId: 'user-123',
      email: 'user@example.com',
      countryCode: 'NG',
    );
    print('Link token created: ${linkToken.linkToken}');

    // Get a binding quote (locks odds for 10 seconds)
    final quote = await puul.predictions.createQuote(
      marketId: market.id,
      outcomeId: market.outcomes.first.id,
      stakeAmount: 100000, // ₦1,000 in minor units
      stakeCurrency: 'NGN',
    );
    print('Quote: estimated return ${quote.estimatedReturn}');

    // Place the prediction with the locked quote
    final prediction = await puul.predictions.place(
      marketId: market.id,
      outcomeId: market.outcomes.first.id,
      stakeAmount: 100000,
      stakeCurrency: 'NGN',
      idempotencyKey: 'example-prediction-001',
      userExternalId: 'user-123',
      quoteId: quote.quoteId,
    );
    print('Prediction placed: ${prediction.id}');
    print('Estimated return: ${prediction.estimatedReturn}');

    // Check wallet balance
    final balance = await puul.wallet.getBalance();
    print('Wallet balance: $balance');
  } on PuulError catch (e) {
    print('API Error: ${e.code} — ${e.message}');
    print('Status: ${e.statusCode}, Retryable: ${e.retryable}');
  } finally {
    // Always clean up the HTTP client
    puul.dispose();
  }
}
0
likes
0
points
467
downloads

Publisher

unverified uploader

Weekly Downloads

Official Dart/Flutter SDK for the Puul Partner API — integrate prediction markets and lottery draws into your mobile app.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

crypto, http

More

Packages that depend on puul_partner_sdk