Hi Everyone,
I am doing the solidity course, right now I am at the end of it and I do not understand the Multisig Project code’s modifier section, where Philip’s code looks the following( I have left he other parts of the code just in case too):
address[] public owners;
uint limit;
mapping(address => mapping(uint => bool)) approvals;
// [address] > [transaction ID] > [yes/no]
struct Transfer {
address payable recipient;
uint approval;
bool approved;
uint amount;
uint transactionID;
}
Transfer[] transferRequests;
constructor(address[] memory _owners, uint _limit){
owners = _owners;
limit = _limit;
}
modifier onlyOwners() {
bool owner = false;
for (uint i = 0; i < owners.length; i++){
if(owners[i] == msg.sender){
owner = true;
}
}
require(owner == true);
_;
}
So I understand the for loop part as have to loop through with the i integet to connect the numbers to the addresses in the address[] array. But why do we need the require(owner == true) at the end? Can someone please explain to me?
Thank you.