BentoSDK

Place a bet

Estimate, place, and reconcile a market bet on the Bento markets host.

Prerequisites

  • Markets host URL (baseUrl)
  • Wallet auth headers configured on createBentoSdk

Flow

import { createBentoSdk, walletAuthProvider } from '@bento.fun/sdk';

const sdk = createBentoSdk({
  baseUrl: process.env.BENTO_URL!,
  auth: walletAuthProvider(() => ({
    'x-wallet-address': walletAddress,
    'x-signature': signature,
    'x-timestamp': String(Date.now()),
  })),
});

// 1. Estimate
const estimate = await sdk.user.bets.estimateBuy({
  duelId: 'your-duel-id',
  option: 'YES',
  amount: '10',
});

// 2. Place (HTTP acceptance)
await sdk.user.placeBet(
  { duelId: 'your-duel-id', option: 'YES', amount: '10' },
  { idempotencyKey: `bet-${duelId}-${Date.now()}` },
);

// 3. Reconcile
const shares = await sdk.user.bets.getUserShares({
  duelId: 'your-duel-id',
  walletAddress,
});

Realtime alternative

Subscribe to duel activity while the bet settles:

const sub = sdk.realtime.subscribeToDuel({
  duelId: 'your-duel-id',
  onEvent: (event) => console.log(event),
});
// sub.close() when done

On this page