How to integrate Bersus game
Bersus is a decentralized platform for conducting one-on-one games with monetary bets. The contract supports bets in both ETH and any ERC20 tokens.
Bersus Smart Contract
source: https://bartio.beratrail.io/address/0xc992332957bfD6DA8E813B9021182f1BC0F35dD1
Contact us in @tg to become bersus partner. Send admin address, fee receiver address and fee size.
Key Features
Creating Game Rooms with Bets: Users can create game rooms specifying the bet amount and the token used for betting.
Joining Existing Rooms: Players can join existing game rooms by matching the bet.
Support for ETH and ERC20 Tokens: Bets can be placed using ETH or any ERC20-compatible tokens.
Random Winner Determination via Pyth Entropy: Utilizes an entropy provider to ensure fair and random selection of the game winner.
Partner Reward System: Implements a system where partners can earn fees based on their participation.
Public Functions
playBersus
playBersus
Creates a new game room.
Parameters:
_partner
: Partner admin address to specify fee receiver (address(0)
for zero partner fee)_token
: Token address used for betting (address(0)
for ETH)._amount
: Bet amount.
Returns: ID of the created room.
joinBersus
joinBersus
Allows a player to join an existing room.
Parameters:
_roomId
: ID of the room to join.
Requirements:
If betting with ETH, sufficient ETH must be sent to cover both the bet and the entropy fee.
If betting with tokens, the player must have approved the contract to spend the specified amount of tokens.
leaveBersus
leaveBersus
Cancels the game and refunds the bet to the room creator.
Parameters:
_roomId
: ID of the room to cancel.
Requirements:
Only the room creator or the contract owner can cancel.
Can only be called before a second player has joined the room.
emergencyLeaveBersus
emergencyLeaveBersus
Emergency cancellation of the game with refunds to both players if the entropy request was not received.
Parameters:
_roomId
: ID of the room to cancel.
Requirements:
Only the room creator or the contract owner can cancel.
Partner Functions
setPartnerFeePercentage
Allows a partner to set their fee percentage.
Parameters:
_partnerFeePercentage
: New fee percentage (in basis points, maximum 1000 = 10%).
setPartnerFeeReceiver
Allows a partner to update the fee receiver address.
Parameters:
_partnerFeeReceiver
: New fee receiver address.
setPartnerAdmin
Allows a partner to transfer admin rights.
Parameters:
_partnerAdmin
: New partner admin address.
View Functions
getPartnerInfo
Retrieves information about a partner.
Parameters:
_partner
: Address of the partner.
Returns: Partner information structure.
getRoom
Retrieves information about a room.
Parameters:
_roomId
: ID of the room.
Returns: Room information structure.
getEntropyFee
Retrieves current fee in wei
Returns: Entropy fee in wei
Events
RoomCreated
: Emitted when a new room is created.BetAccepted
: Emitted when a second player joins a room.GameFinished
: Emitted when a game concludes and a winner is determined.RoomCancelled
: Emitted when a room is canceled.PartnerAdded
: Emitted when a new partner is added.PartnerRemoved
: Emitted when a partner is removed.PartnerUpdated
: Emitted when a partner's information is updated.
Last updated