Changes to the OptimismMintableERC20 contract
This section documents the most notable changes made to the Optimism OptimismMintableERC20 contract. Some trivial changes may not be explicitly discussed, including, for example, changes made to support access of contract storage in a way compatible with the upgradability pattern adopted by Facet.
Immutable parameters changed to storage variables
The standard Optimism contract stores the address of the remote token and of the bridge as immutable parameters — set by the constructor directly in the contract bytecode at initialization time. This change was introduced to support the storage-access pattern chosen by Facet. However, we note that the parameters are now technically not immutable anymore; a function setBridgeAndRemoteToken
allows the owner of the contract to change the addresses of the bridge and remote token.
New selfBurn
function
The Facet version of the contracts added a selfBurn
function, which allows to burn an amount of tokens; the function is safe, as the tokens are taken from msg.sender
.
Inheritance from FacetERC20
The Facet version of OptimismMintableERC20 inherits from a base contract named FacetERC20. This base contract implements a few trivial getters (name, symbol, decimal), but most importantly it implements overrides to transferFrom
and allowance
to support the buddy addresses functionality during migration. This functionality existed in the legacy Facet version and allowed users to delegate permissions to a buddy address which could operate on their tokens on their behalf. Reviewing the buddy functionality was not part of the scope of this engagement. As of commit , these overrides only work while the Facet v0 → v1 migration is ongoing, and are automatically disabled afterwards.
The base contract also implements a function emitTransferEvent
, which is used in the last stage of the migration. The function can only be invoked by the special migration manager contract and emits a bogus transfer event that can be used by off-chain indexers to bootstrap the database that records the owners of the ERC-20.