'how to convert array static to dynamic in solidity?
This code is a betting smart contract. How can I convert the static payout to dynamic? The structure is only Hardcode 1:1 static payout odds. How can I convert it to dynamic?
source code full:https://testnet.bscscan.com/address/0x9b0188b17db3e6bfbd4597562634bc45c214f37e#code
function claimBetPayout(uint _betId) external {
Bet storage bet = bets[_betId];
Event memory betEvent = events[bet.eventId];
require(msg.sender == bet.bettor, "Only original bettor address can claim payout");
require(betEvent.result == bet.option, "Only winning bets can claim payout");
require(bet.claimed == 0, "Bet payout was already claimed");
uint payoutAmount = calculateBetPayoutAmount(bet);
msg.sender.transfer(payoutAmount);
bet.claimed = 1;
}
}
Above is the claimBetPayout function that payouts fix value. How to claim multiple results in events?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
