Skip to content

Enhance encapsulation of StandardToken #1097

@frangio

Description

@frangio

Currently BasicToken and StandardToken use internal state variables to track balances, and provides no functions to create balance. Thus, contracts that need to create balance (which is all tokens because by default there will be zero balance) have to manually modify those internal state variables. This is pretty bad UX, and it's breaking encapsulation.

Example:
https://github.com/OpenZeppelin/openzeppelin-solidity/blob/67b67b791ed7a24aa027ea2d17efd5e4d02b4277/contracts/token/ERC20/MintableToken.sol#L44-L47

BasicToken's and StandardToken's state variables should be private, and there should be internal functions _mint and _burn that modify them and emit the necessary events.

See ERC721BasicToken for an example:
https://github.com/OpenZeppelin/openzeppelin-solidity/blob/67b67b791ed7a24aa027ea2d17efd5e4d02b4277/contracts/token/ERC721/ERC721BasicToken.sol#L255-L259

Metadata

Metadata

Assignees

Labels

good first issueLow hanging fruit for new contributors to get involved!

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions