0

Say, the role-based access control consists of two roles. But if I want to replace the roles to maybe location and time, how to go about it?

0

The short answer is you would make your own access control. RBAC is a specific approach.

A suggestion would be to use the even simpler Ownable.sol (OpenZeppelin) example as a template, for ideas.

The basic idea is to define your guards.

modifier afterMidnight {
  // require(something, "patience. party hasn't started");
  _;
}

function living() public afterMidnight ...

You can pass arguments, including inputs:

modifier onlyOver1000(uint input) {
  require(input > 1000, "too small");
  _;
}

function doSomething(uint amount) public onlyOver1000(amount) ...

After that, it usually boils down to state variables you will need to work out the conditional logic. Ownable.sol is simple that way. It needs to store the Owner address so it does that, and provides a way to change, emits events when it should, and is just organized well for re-use in sensible structures.

Geographic conditions will be exceptionally challenging because Ethereum is non-local. A number of projects are working on various approaches to proof of location. If that is a genuine interest and not merely an Adhoc example, I might suggest another question to explore that in particular.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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