Placing a bet

How to place a bet using Interactive Streaming.

To allow users to place a bet, pass onBetPlaced

type OnBetPlaced = (args: PlaceBetArgs) => Promise<PlaceBetSuccess>;

interface PlaceBetArgs {
  stake: string;
  market: Market;
  option: MarketOption;
  requestId: string;
}


interface PlaceBetSuccess {
  marketName: string;
  optionName: string;
  stake: string;
  odds: string;
  betRef: string;
}

class SDKError extends Error {
  constructor(message: string) {
    super(message || 'Unknown Error');
    this.name = 'SDKError';
  }
}

onBetPlaced callback should return a Promise which resolves to PlaceBetSuccess if the bet was successfully placed and should reject with an SDKError and a message to the user if placing the bet fails or something unexpected went wrong.

The requestId is exposed for enabling idempotence. It is changed when the market, option or value of the bet changes or if the betting interface is closed and reopened or when the bet is accepted with PlaceBetSuccess.

Last updated