rewardPool is meaningless.
In this contract, rewardPool seems to define the types of rewards, and allows the owner to add types of rewards externally.
The list of kinds of rewards is configured, but when opening the box, the code related with rewards are hard coded, so rewardPool has no real meaning.
...
constructor() payable {
owner = msg.sender;
boxPrice = 0.1 ether;
require(msg.value >= SEEDVALUE, "Incorrect ETH sent");
rewardPool.push(Reward("Gold Coin", 0.5 ether)); [found]
rewardPool.push(Reward("Silver Coin", 0.25 ether)); [found]
rewardPool.push(Reward("Bronze Coin", 0.1 ether)); [found]
rewardPool.push(Reward("Coal", 0 ether)); [found]
}
...
function addReward(string memory _name, uint256 _value) public {
require(msg.sender == owner, "Only owner can add rewards");
rewardPool.push(Reward(_name, _value));
}
...
function openBox() public {
require(boxesOwned[msg.sender] > 0, "No boxes to open");
uint256 randomValue = uint256(keccak256(abi.encodePacked(block.timestamp, msg.sender))) % 100;
if (randomValue < 75) {
rewardsOwned[msg.sender].push(Reward("Coal", 0 ether));
} else if (randomValue < 95) {
rewardsOwned[msg.sender].push(Reward("Bronze Coin", 0.1 ether));
} else if (randomValue < 99) {
rewardsOwned[msg.sender].push(Reward("Silver Coin", 0.5 ether));
} else {
rewardsOwned[msg.sender].push(Reward("Gold Coin", 1 ether));
}
boxesOwned[msg.sender] -= 1;
}
This may cause backlash from users as the contract does not operate according to the compensation rules set by the owner.
It can be changed the openBox function to input the rewardsOwned value based on the value set in rewardPool.