[Ethereum] how to create multiple owners : Solidity

ethereum-classicsolidity

I am creating a contract in which i want is like multiple owners have the rights to whitelist the user.

contract Whitelist {

    mapping(address => bool) Users;
    address private owner;
    address private otherOwner;

    function Whitelist() {
        owner = msg.sender;
    }
//Modifier for owner access
    modifier onlyOwner() {
        require(owner == msg.sender);
            _;
    }
//Function to add users
    function userAdd(address userAddress) onlyOwner {
            require(userAddress != 0x0 && !Users[userAddress]);             
            Users[userAddress] = true;    

    }
//Checking the user is whitelist
    function isWhitelisted(address passAddress) external returns (bool) {   
        return Users[passAddress];
    }

i am not getting idea about how to do that.
need help.
thanks in advance.

Best Answer

You can use RBAC.sol contract from OpenZeppelin https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/ownership/rbac/RBAC.sol.

It has onlyAdmin and onlyRole modifiers. Multiple users holding different roles can be added. You can have arbitrary roles e.g. WHITELISTED.

Alternatively you can use Whitelist.sol contract https://github.com/OpenZeppelin/zeppelin-solidity/pull/746/files#diff-8d5f210f8ce2e6f8d7f62f655e6f72ec

Related Topic