Use access control accross multiple contracts


I had a small question related to the access control mechanism

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.