Acceptance vs finality
A write means "accepted", not "settled". How to confirm the real result.
When you place a bet or create a market, the call returns once the server accepts it, not when the chain has settled. It may still validate, queue, or submit the transaction. So the pattern is always: write, then confirm.
Confirm the result
- Poll a read:
getUserShares, tournament detail / entry status waitFor*helpers:waitForTournamentEntry(takes a status-getter)
There's no universal waitForFinality(); the server doesn't expose a status API for every write.
Idempotency
Pass a caller-stable idempotencyKey on writes so a retry can't double-submit:
await sdk.user.placeBet(body, { idempotencyKey: 'bet-unique-id' }); // stable, not Date.now()On-chain writes
sdk.onchain.* sends the transaction via your viem wallet and returns { success, txHash?, error? }. It never throws, so branch on success:
import { waitForTournamentEntry } from '@bento.fun/sdk';
const res = await sdk.onchain!.depositAndEnterTournament(tournamentId, {
amountUsdc: '100',
});
if (!res.success) throw new Error(res.error);
await waitForTournamentEntry(() =>
sdk.tournaments!.tournaments.getMyStatus(tournamentId),
);