Coinflip
Use Coinflip when you want to build a standard heads-or-tails wager.
What the builder does
createBetTransaction('coinflip', options) builds the Move call for Suigar Coinflip and sends the reward object back to owner.
Required options
ownercoinTypestakeside:'heads' | 'tails'
Shared optional options
cashStakebetCountmetadatagasBudgetallowGasCoinShortcut
Example
const tx = client.suigar.tx.createBetTransaction('coinflip', {
owner: '0x123',
coinType: '0x2::sui::SUI',
stake: 1_000_000_000n,
side: 'tails',
});
Typical usage
The usual Coinflip flow is:
- read the live stake bounds for the selected coin
- let the player choose
headsortails - build the transaction
- sign and execute it
- decode the resulting
BetResultEventif you want structured outcome data
Read current limits
If your app needs to validate stake before building the transaction, read the live onchain parameters first:
const parameters = await client.suigar.getGameParameters('coinflip', {
coinType: '0x2::sui::SUI',
});
console.log(parameters.min_stake);
console.log(parameters.max_stake);
This is the simplest pattern for:
- showing the allowed stake range in a bet form
- blocking stale client-side inputs before building the transaction
- re-checking limits on the server before signing or forwarding a request
Notes
side: 'tails'is converted by the SDK into the boolean expected by the contract call.metadatais optional and gets encoded into thekeysandvaluesarrays used on-chain.- reserved metadata keys such as
partnerandreferrerare ignored with a warning when passed manually - if the client was registered with
suigar({ partner: '0x...' }), partner attribution is added automatically min_stakeandmax_stakecome from the live coin-specific parameter object, so avoid hardcoding them in product code