Access control between contracts

Hi,

new to forum so if this question belongs elsewhere please let me know.

I'm new to solidity and trying to wrap my head around access control between contracts (if this is even possible).

Say I have a mint function in MyToken contract. I would like a Farm contract as well as a Reward contract to be able to mint MyTokens.

How would I go about setting up access control between these contracts? I understand how roles can work in a singular contract, but I'm unsure on how roles can be set up in the other contracts. Would I just use my admin to grant a role (Minter) to the other contracts address? If one of these was a UUPS proxy, do I grant the role to the proxy address?

Thanks for any help

Hi @TJakubek,

What you're asking about is definitely possible, and you seem to be on the right track. You should use your admin to call the function grantRole on your token, with the arguments set to the MINTER_ROLE id and the address of your Farm contract. Then do the same with the address of your Reward contract.

I encourage you to try this out in a test and see how it works.

Awesome, thanks for the answer Francisco. Will test it out for sure.
BTW thanks for the awesome youtube tutorials, as a beginner your explanations really let everything click in my head better than after reading a wall of text.
Cheers

1 Like