1

Suppose there is a mapping mapping (address => bool) submitted. How to access this mapping's data from test script??

1 Answer 1

0

for accessing mapping from outside there is two ways.

  1. 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)

  2. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.