Suppose there is a mapping mapping (address => bool) submitted
.
How to access this mapping's data from test script??
1 Answer
for accessing mapping from outside there is two ways.
you can make your mapping visibilty to public and solidity automaticly creat a getter function for it e.g
mapping (address => bool) public submitted
and you can access it like this :const isSubmited = await Contract.submitted(myAddress)
you can create getter function for it by your self e.g
mapping (address => bool) submitted;
function getSubmitted(address myAddress) public returns(bool){
return submitted[myAddress];
}
and you can access it same before const isSubmited = await Contract.getSubmitted(myAddress)
both do the same.