Romuald Hog (based on Yakitori's Coin Toss)
BetSwirl's Coin Toss game
The game is played with a two-sided coin. The game's goal is to guess whether the lucky coin face will be Heads or Tails.
function bank() external view returns (contract IBank)
The bank that manage to payout a won bet and collect a loss bet.
Name | Type | Description |
---|---|---|
_0 | contract IBank | undefined |
function bets(uint256) external view returns (bool resolved, address user, address token, uint256 id, uint256 amount, uint256 blockNumber, uint256 payout, uint256 vrfCost)
Maps bets IDs to Bet information.
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
Name | Type | Description |
---|---|---|
resolved | bool | undefined |
user | address | undefined |
token | address | undefined |
id | uint256 | undefined |
amount | uint256 | undefined |
blockNumber | uint256 | undefined |
payout | uint256 | undefined |
vrfCost | uint256 | undefined |
function coinTossBets(uint256) external view returns (bool face, bool rolled)
Maps bets IDs to chosen and rolled coin faces.
Coin faces: true = Tails, false = Heads.
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
Name | Type | Description |
---|---|---|
face | bool | undefined |
rolled | bool | undefined |
function getChainlinkConfig() external view returns (uint16 requestConfirmations, bytes32 keyHash, contract IVRFCoordinatorV2 chainlinkCoordinator, uint256 gasAfterCalculation)
Returns the Chainlink VRF config.
Name | Type | Description |
---|---|---|
requestConfirmations | uint16 | undefined |
keyHash | bytes32 | undefined |
chainlinkCoordinator | contract IVRFCoordinatorV2 | undefined |
gasAfterCalculation | uint256 | undefined |
function getChainlinkVRFCost(address token) external view returns (uint256)
Returns the amount of ETH that should be passed to the wager transaction. to cover Chainlink VRF fee.
Name | Type | Description |
---|---|---|
token | address | undefined |
Name | Type | Description |
---|---|---|
_0 | uint256 | The bet resolution cost amount. |
function getLastUserBets(address user, uint256 dataLength) external view returns (struct CoinToss.FullCoinTossBet[])
Gets the list of the last user bets.
Name | Type | Description |
---|---|---|
user | address | Address of the gamer. |
dataLength | uint256 | The amount of bets to return. |
Name | Type | Description |
---|---|---|
_0 | CoinToss.FullCoinTossBet[] | A list of Coin Toss bet. |
function hasPendingBets(address token) external view returns (bool)
Returns whether the token has pending bets.
Name | Type | Description |
---|---|---|
token | address | undefined |
Name | Type | Description |
---|---|---|
_0 | bool | Whether the token has pending bets. |
function multicall(bytes[] data) external nonpayable returns (bytes[] results)
Receives and executes a batch of function calls on this contract.
Name | Type | Description |
---|---|---|
data | bytes[] | undefined |
Name | Type | Description |
---|---|---|
results | bytes[] | undefined |
function owner() external view returns (address)
Returns the address of the current owner.
Name | Type | Description |
---|---|---|
_0 | address | undefined |
function pause() external nonpayable
Pauses the contract to disable new bets.
function paused() external view returns (bool)
Returns true if the contract is paused, and false otherwise.
Name | Type | Description |
---|---|---|
_0 | bool | undefined |
function rawFulfillRandomWords(uint256 requestId, uint256[] randomWords) external nonpayable
Name | Type | Description |
---|---|---|
requestId | uint256 | undefined |
randomWords | uint256[] | undefined |
function refundBet(uint256 id) external nonpayable
Refunds the bet to the user if the Chainlink VRF callback failed.
Name | Type | Description |
---|---|---|
id | uint256 | The Bet ID. |
function renounceOwnership() external nonpayable
Leaves the contract without owner. It will not be possible to call onlyOwner
functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.
function setChainlinkConfig(uint16 requestConfirmations, bytes32 keyHash, uint256 gasAfterCalculation) external nonpayable
Sets the Chainlink VRF V2 configuration.
Name | Type | Description |
---|---|---|
requestConfirmations | uint16 | How many confirmations the Chainlink node should wait before responding. |
keyHash | bytes32 | Hash of the public key used to verify the VRF proof. |
gasAfterCalculation | uint256 | Gas to be added for VRF cost refund. |
function setHouseEdge(address token, uint16 houseEdge) external nonpayable
Sets the game house edge rate for a specific token.
The house edge rate couldn't exceed 4%.
Name | Type | Description |
---|---|---|
token | address | Address of the token. |
houseEdge | uint16 | House edge rate. |
function setVRFCallbackGasLimit(address token, uint32 callbackGasLimit) external nonpayable
Sets the Chainlink VRF V2 configuration.
Name | Type | Description |
---|---|---|
token | address | undefined |
callbackGasLimit | uint32 | How much gas is needed in the Chainlink VRF callback. |
function tokens(address) external view returns (uint16 houseEdge, uint64 pendingCount, uint32 VRFCallbackGasLimit, uint256 VRFFees)
Maps tokens addresses to token configuration.
Name | Type | Description |
---|---|---|
_0 | address | undefined |
Name | Type | Description |
---|---|---|
houseEdge | uint16 | undefined |
pendingCount | uint64 | undefined |
VRFCallbackGasLimit | uint32 | undefined |
VRFFees | uint256 | undefined |
function transferOwnership(address newOwner) external nonpayable
Transfers ownership of the contract to a new account (newOwner
). Can only be called by the current owner.
Name | Type | Description |
---|---|---|
newOwner | address | undefined |
function userOverchargedVRFCost(address) external view returns (uint256)
Maps user addresses to VRF overcharged cost.
Name | Type | Description |
---|---|---|
_0 | address | undefined |
Name | Type | Description |
---|---|---|
_0 | uint256 | undefined |
function wager(bool face, address token, uint256 tokenAmount) external payable
Creates a new bet and stores the chosen coin face.
Name | Type | Description |
---|---|---|
face | bool | The chosen coin face. |
token | address | Address of the token. |
tokenAmount | uint256 | The number of tokens bet. |
function withdrawOverchargedVRFCost(address user) external nonpayable
Withdraw user's overcharged Chainlink fees.
Name | Type | Description |
---|---|---|
user | address | undefined |
function withdrawTokensVRFFees(address token) external nonpayable
Distributes the token's collected Chainlink fees.
Name | Type | Description |
---|---|---|
token | address | Address of the token. |
event AccountOverchargedVRFCost(address indexed user, uint256 overchargedVRFCost)
Emitted after the overcharged VRF cost amount is accounted.
Name | Type | Description |
---|---|---|
user indexed |
address | undefined |
overchargedVRFCost | uint256 | undefined |
event BetRefunded(uint256 id, address user, uint256 amount, uint256 chainlinkVRFCost)
Emitted after the bet amount is transfered to the user.
Name | Type | Description |
---|---|---|
id | uint256 | undefined |
user | address | undefined |
amount | uint256 | undefined |
chainlinkVRFCost | uint256 | undefined |
event DistributeOverchargedVRFCost(address indexed user, uint256 overchargedVRFCost)
Emitted after the user's overcharged VRF cost amount is transfered.
Name | Type | Description |
---|---|---|
user indexed |
address | undefined |
overchargedVRFCost | uint256 | undefined |
event DistributeTokenVRFFees(address indexed token, uint256 amount)
Emitted after the token's VRF fees amount is transfered to the user.
Name | Type | Description |
---|---|---|
token indexed |
address | undefined |
amount | uint256 | undefined |
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)
Name | Type | Description |
---|---|---|
previousOwner indexed |
address | undefined |
newOwner indexed |
address | undefined |
event Paused(address account)
Name | Type | Description |
---|---|---|
account | address | undefined |
event PlaceBet(uint256 id, address indexed user, address indexed token, uint256 amount, uint256 vrfCost, bool face)
Emitted after a bet is placed.
Name | Type | Description |
---|---|---|
id | uint256 | The bet ID. |
user indexed |
address | Address of the gamer. |
token indexed |
address | Address of the token. |
amount | uint256 | The bet amount. |
vrfCost | uint256 | The Chainlink VRF cost paid by player. |
face | bool | The chosen coin face. |
event Roll(uint256 id, address indexed user, address indexed token, uint256 amount, bool face, bool rolled, uint256 payout)
Emitted after a bet is rolled.
Name | Type | Description |
---|---|---|
id | uint256 | The bet ID. |
user indexed |
address | Address of the gamer. |
token indexed |
address | Address of the token. |
amount | uint256 | The bet amount. |
face | bool | The chosen coin face. |
rolled | bool | The rolled coin face. |
payout | uint256 | The payout amount. |
event SetChainlinkConfig(uint16 requestConfirmations, bytes32 keyHash, uint256 gasAfterCalculation)
Emitted after the Chainlink config is set.
Name | Type | Description |
---|---|---|
requestConfirmations | uint16 | undefined |
keyHash | bytes32 | undefined |
gasAfterCalculation | uint256 | undefined |
event SetHouseEdge(address indexed token, uint16 houseEdge)
Emitted after the house edge is set for a token.
Name | Type | Description |
---|---|---|
token indexed |
address | undefined |
houseEdge | uint16 | undefined |
event SetVRFCallbackGasLimit(address indexed token, uint32 callbackGasLimit)
Emitted after the Chainlink callback gas limit is set for a token.
Name | Type | Description |
---|---|---|
token indexed |
address | undefined |
callbackGasLimit | uint32 | undefined |
event Unpaused(address account)
Name | Type | Description |
---|---|---|
account | address | undefined |
error AccessDenied()
Reverting error when sender isn't allowed.
error ExcessiveHouseEdge()
House edge is capped at 4%.
error ForbiddenToken()
Token is not allowed.
error InvalidAddress()
Reverting error when provided address isn't valid.
error InvalidLinkWeiPrice(int256 linkWei)
Chainlink price feed not working
Name | Type | Description |
---|---|---|
linkWei | int256 | LINK/ETH price returned. |
error NoOverchargedVRFCost()
No user's overcharged Chainlink fee.
error NotFulfilled()
Bet isn't resolved yet.
error NotPendingBet()
Bet provided doesn't exist or was already resolved.
error OnlyCoordinatorCanFulfill(address have, address want)
Name | Type | Description |
---|---|---|
have | address | undefined |
want | address | undefined |
error TokenHasPendingBets()
Reverting error when token has pending bets.
error UnderMinBetAmount(uint256 minBetAmount)
Insufficient bet amount.
Name | Type | Description |
---|---|---|
minBetAmount | uint256 | Bet amount. |
error WrongGasValueToCoverFee()
The msg.value is not enough to cover Chainlink's fee.