Skip to main content

PvP Coinflip

PvP Coinflip uses a dedicated builder because the flow has multiple actions instead of a single bet entrypoint.

What the builder does

createPvPCoinflipTransaction(action, options) builds one of three flows:

  • create
  • join
  • cancel

If you are a partner, configure suigar({ partner: '0xpartner_wallet_address' }) on the client before using any of these flows.

Create a game

Use this when a player opens a new PvP Coinflip lobby.

const tx = client.suigar.tx.createPvPCoinflipTransaction('create', {
playerAddress: '0x123',
coinType: '0x2::sui::SUI',
stake: 1_000_000_000n,
side: 'heads',
isPrivate: false,
});

Required action-specific fields:

  • stake
  • side

Optional action-specific fields:

  • isPrivate

Join a game

Use this when a second player joins an existing PvP Coinflip.

const tx = client.suigar.tx.createPvPCoinflipTransaction('join', {
playerAddress: '0x123',
coinType: '0x2::sui::SUI',
gameId: '0xGAME_ID',
});

Required action-specific fields:

  • gameId

Cancel a game

Use this when the creator needs to cancel an unresolved lobby.

const tx = client.suigar.tx.createPvPCoinflipTransaction('cancel', {
playerAddress: '0x123',
coinType: '0x2::sui::SUI',
gameId: '0xGAME_ID',
});

Required action-specific fields:

  • gameId

Discover open lobbies

Use the runtime helpers when you need to render open games or inspect a live lobby before joining:

const games = await client.suigar.getPvPCoinflipGames({ limit: 20 });
const game = await client.suigar.resolvePvPConflipGame('0xGAME_ID');

Notes

  • join derives the required stake from gameId and uses the configured price info object automatically
  • partner attribution is injected automatically when the extension is registered with partner
  • partner attribution should not be passed manually in each PvP builder call
  • PvP Coinflip also exposes BCS structs for created, resolved, and cancelled events through client.suigar.bcs.