Skip to content

Consider alternative design for token transfers and hooks #3535

Closed
@frangio

Description

@frangio

The way to customize token transfers today is by overriding the hooks _beforeTokenTransfer and _afterTokenTransfer. This was designed this way because there are multiple related operations (mint, transfer, burn) that would generally be customized in a uniform way (e.g. "pause transfers" should also pause mints), and they are different functions all of which invoke the same hooks.

An alternative that we can consider is instead to have a single entry point for all of these operations, a _transfer function that mints if the "from" argument is 0, etc., as suggested in #3109 for ERC20 (the same applies to other tokens). Hooks can then be removed because customizing transfers can be done by overriding this single function instead of overriding the hooks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeChanges that break backwards compatibility of the public API.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions