2

I am reading the contracts of OpenZeppelin, in particular the ERC20.sol. I see that they could use immutable in the case of the name and symbol, but they are not using its. They they prefear a stard private variable instead of inmutable?

    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

1 Answer 1

1

That is because immutable variables can not have a non-value type i.e string here check out docs for more information on same. Check out docs to find out more about all value type.

2
  • But, why is non-value type? You can use immutable with strings. Nov 15, 2021 at 23:25
  • As mentioned in [docs] (docs.soliditylang.org/en/latest/…) "Not all types for constants and immutables are implemented at this time. The only supported types are strings (only for constants) and value types." Nov 16, 2021 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.