Use access control accross multiple contracts

Hi,

I had a small question related to the access control mechanism https://docs.openzeppelin.com/contracts/3.x/access-control#role-based-access-control

does the role remain relevant from one contract context to another i.e if I have 1 main contract and assign an admin role there and call another contract so can I use

require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller is not a burner");
inside a function in another contract ?

I think the answer is no. You may have noticed AccessControl is an abstract contract. State variables and functions only exist in the scope of the contract that inherits from it. Other contracts do not share state variables with this contract. However, if an AccessControl mechanism is desired to be established across smart contracts, AccessControl contract can be inherited by an external storage contract so that all other contracts in this dapp would share common state variables, of course including role variables.

1 Like