When I try to mint inside of constructor using ERC20Capped
from OpenZeppelin 4 like
contract SomeERC20 is ERC20Capped {
constructor (
string memory name,
string memory symbol,
uint256 cap,
uint256 initialBalance
)
ERC20(name, symbol)
ERC20Capped(cap)
{
_mint(_msgSender(), initialBalance);
}
}
the error
Immutable variables cannot be read during contract creation time, which means they cannot be read in the constructor or any function or modifier called from it
appears.
What should I do?