Claim Winnings
The winnerClaim and claimOldWinnings functions allow users to claim their winnings from the contract. These functions check the current state of the contract, calculate the winnings, and then transfer
Function Breakdown
Both functions first check if the contract is in the
Resolved
state. If not, they revert the transaction.They then check if the user has any winnings to claim. If not, the functions revert the transaction.
The functions then calculate the winnings, which is the proportion of the total bet amount that the user bet on the winning outcome.
The
transfer
function of the PBetsToken contract is then called, which transfers the winnings from the contract to the user.Finally, a
Claimed
event is emitted, with the user's address, the amount of winnings, and the current version of the contract.
Last updated