// __ Mapping __
mapping (address => uint) approvedUsers;
// __ Function to add addresses to the mapping___
function _addApprover(address _approver, uint _i) public{
approvedUsers[_approver] += approvedUsers[_i];
}
// ___ user from mapping checked and if true then the rate can be change, else not_
function pricing(address _user, uint _rate) public{
require(approvedUsers[_user] == approvedUsers,"User not in the approvers list");
rate = _rate * (10 ** uint256(decimals())); }
I think you want authenticate some addresses to change the rate and other addresses are not able to do.
To do so, you should (There are other ways but this is easier) do this:
//First you declare owner to have access to approve or disapprove users
address owner;
//Then you declare mapping
mapping(address=>bool) approvedUsers;
//Automatically all addresses return false so no one has access to it.
//In constructor, you specify the owner
constructor(){
owner = msg.sender
}
//By using msg.sender, contract who deployed contract will be owner.
//A modify to make some functions just callable by owner
modifier isOwner(){
require(msg.sender == owner, "Access denied");
_;
}
//Now function to approve and disapprove users
function _addApprover(address _approver) public isOwner{
approvedUsers[_approver] = true;
function _removeApprovedUser(address _disapprover) public isOwner{
approvedUsers[_disapprover] = false;
//Now change rating function
function pricing(uint _rate) public{
require(approvedUsers[msg.sender],"User not in the approvers list");
//Because approvedUsers mapping returns a bool, you do not need to compare it and if it is true,
//user have access to change and if it is false user does not have access to change it
rate = _rate * (10 ** uint256(decimals()));
}