Hello Ethereum community,
I have couple of structs in my solidity code to organize things. Here is one struct from the code:
struct Staking {
uint total;
uint currentIndex;
mapping(address => uint) registry;
}
Staking public staking;
When compiling, I also get a staking() getter in the abi. Now on my frontend I have configured ethers npm library and am trying to retrive all of my structs. Calling
const data = await ethers.gameContract.staking();
Gives me this, JSON.stringified
[{"type":"BigNumber","hex":"0x00"},{"type":"BigNumber","hex":"0x00"}]
I can confirm that those two are total and currentIndex uints. But I can't see registry mapping.
Is there a way to query data modeled like this, or should I just declare all these properties in the top level of contract block (which should solve the issue by creating a getter for each prop in the abi), or maybe create custom getter functions that will retrieve these nested mappings?
EDIT: Calling staking() from the Remix in VSCode, I get this data:
{"0":"0","1":"0","total":"0","lastIndex":"0"}
Now I'm definitely confused. Are the first 2 items in this object, "0" and "1" keys actually items from the mapping? Maybe I am asking a wrong question here. But I still can't figure out how to query this mapping.
Thanks!