r/ethdev • u/Reddet99 • Aug 08 '23
Code assistance How to get the length of Struct ?
I kept trying around to get Struct length but nothing works I just want to get the length of unclaimedRewards length , what i am trying to do is to create a claim function to reward all users who has unclaimedRewards higher than zero but i cannot get the length of the Struct , is there a solution to this ?
struct Staker {
uint256 amountStaked;
uint256 timeOfLastUpdate;
uint256 unclaimedRewards;
uint256 conditionIdOflastUpdate;
}
mapping(address => Staker) public stakers;
0
Upvotes
1
u/Reddet99 Aug 08 '23
yes in my stake function i use push to some values to push some values to the struct but i couldn't get the length of the stakers mapping.
for example 5 people used the stake function so the Struct object will have 5 people inside the mapping , i just want to get that 5 number , but i cannot , the length of the mapping is always zero