I tried to deploy both ERC20 contracts with burn functionality over the remix and both seems to work fine, I am confused if one way should be preferred over the other. Since, openzeppelin contract wizard seems to implement the first way but for me the second also works just fine. Can someone point out where I am going wrong, inheritance is getting confusing for me.
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
contract MyToken is ERC20, ERC20Burnable {
constructor() ERC20("MyToken", "MTK") {
_mint(msg.sender, 2000 * 10 ** decimals());
}
}
OR
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
contract MyToken is ERC20Burnable {
constructor() ERC20("MyToken", "MTK") {
_mint(msg.sender, 2000 * 10 ** decimals());
}
}