Open vikramIde opened 3 years ago
contract ERC20FixedSupply is ERC20 {
constructor() public {
totalSupply += 1000;
balances[msg.sender] += 1000;
}
}
contract ERC20FixedSupply is ERC20 {
constructor() public ERC20("Fixed", "FIX") {
_mint(msg.sender, 1000);
}
}
Starting with Contracts v2 this pattern is not only discouraged, but disallowed. The variables totalSupply and balances are now private implementation details of ERC20, and you can’t directly write to them. Instead, there is an internal _mint function that will do exactly this:
https://docs.openzeppelin.com/contracts/3.x/erc20-supply