Hi i am trying to use 2 modifiers in one function.
ex:
function a(uint id) public view (isValid (id) || isKey(id)) returns (string memory){
//body
}

Now, what i sont know is can i use 2 modifiers?Cauz i am getting an error.

Jul 9, 2022, 7:29 PM
What i wanted to do is I have 2 modifiers checking different things and either can be true. So that is why i was going for OR.
But it seems i cant use that.
Is there any other way round for this?
so i have a different contract where there are modifiers and i have inherited that contract to My main contract, but now what i have created is 2 checks. Either the number can be valid or a key.

There exists 2 functions 1. Key that uses isValid() modifier and
2. Valid function that uses isKey() modifier.

and with both of these functions a mapping is being done globally in contract
mapping(uint=>access)p;
mapping(uint=>access)q;

And now while retrieving the data i want the data to be retrieved. but with any of these the data can be retrieved.
So i was trying like this.

function a(uint id) public view (isValid (id) || isKey(id)) returns (string memory){
//body

}

...
and it is for sure that these 2 mapping needa to be seperate. Because of their usage.
Now how can i use 2 modifier such that if any one of them is true execute the function otherwise don't execute the function.
Jul 9, 2022, 8:06 PM

© 2024 Draquery.com All rights reserved.