After deployment when I try to execute this function that requires an account having MINTER_ROLE:
function mint(address to, uint256 amount) public onlyRole(MINTER_ROLE) {
_mint(to, amount);
}
an error occurs that says [wallet account] is missing role [hash of MINTER_ROLE] even though [wallet account] is the one that originally initiated the deployment.
When I run getRoleMember I found that msg.sender happened to be constAddressDeployer address when grantRole was called, instead of the [wallet account].
So how can we make sure that grantRole takes [wallet account] that initiated the deployment?
I added role based access to a cross chain token contract using OpenZeppelin's grantRole, and used
deployUpgradable
like in the examples.DEFAULT_ADMIN_ROLE
andMINTER_ROLE
are granted on deployment of the contract:After deployment when I try to execute this function that requires an account having MINTER_ROLE:
an error occurs that says [wallet account] is missing role [hash of MINTER_ROLE] even though [wallet account] is the one that originally initiated the deployment.
When I run getRoleMember I found that
msg.sender
happened to beconstAddressDeployer
address whengrantRole
was called, instead of the [wallet account].So how can we make sure that
grantRole
takes [wallet account] that initiated the deployment?