I am trying to create a mapping inside struct and then create a mapping of the struct. Take a look at below example:
// ------------------------------------------------------------------------
// Each Level related details are stored using `Level` struct
// ------------------------------------------------------------------------
struct Level{
address payable luckyDraw;
uint256 dividend;
address payable topHolder;
uint256 topInvestment;
uint256 reversedAllowed;
mapping(address => uint256) userReversed;
mapping (uint => address payable) levelUsers;
uint256 ETH_REVERSED;
uint256 countDeposit;
uint totalBuyers;
}
mapping (uint => Level) public payouts; // keeps record of each payout
Now here, the payouts saves record of the Level(struct), you can see the struct which have two mapping as well other than other member variables.
When I try to read the payouts, I can never read about these mappings, also it seems that I can never save any record inside these mappings. I am trying to save data for levelUsers but it doesn't seems to work, If I try to read this, it returns me 0x0000.
// add the purchaser address to the all users array
payouts[1].levelUsers[0] = msg.sender;
address payable user = payouts[1].levelUsers[0];
The user is always 0x000, seems it never saves successfully
Are my declarations all good?
it doesn't seems to work
(how do you determine that, what error do you get, etc). – goodvibration Apr 2 '20 at 15:35The user is always 0x000
? – goodvibration Apr 2 '20 at 15:39