ERC-5679 · Final · ERC · 2022-09-17
ERC-5679: Token Minting and Burning
Standard mint and burn function signatures for ERC-20, ERC-721 and ERC-1155 tokens, so tools and contracts can create and destroy tokens the same way across collections.
What problem does it solve?
ERC-20, ERC-721 and ERC-1155 define how tokens move, but not how they are created or destroyed. Every project invents its own mint, mintTo, issue or burnFrom, and some reuse transfer functions for it. Minting and burning change total supply and normally have different permission rules than transfers, so mixing them in is a source of bugs.
ERC-5679 gives each of the three token standards a dedicated, predictable pair of functions for creating and destroying tokens.
How it works
There is one small interface per base standard, each with its own ERC-165 ID:
| Base | Interface | ERC-165 ID | Functions |
|---|---|---|---|
| ERC-20 | IERC5679Ext20 |
0xd0017968 |
mint(to, amount, data), burn(from, amount, data) |
| ERC-721 | IERC5679Ext721 |
0xcce39764 |
safeMint(to, id, data), burn(from, id, data) |
| ERC-1155 | IERC5679Ext1155 |
0xf4cedd5a |
safeMint, safeMintBatch, burn, burnBatch |
Rules shared by all three:
- No new events. A mint emits the base standard's normal transfer event from
address(0)to the recipient; a burn emits one from the holder toaddress(0). Indexers that already track transfers see supply changes for free. - Supply must change. Total supply goes up on mint and down on burn.
safeMintis safe. For ERC-721 and ERC-1155 it applies the same receiver checks assafeTransferFrom, so tokens are not minted into contracts that cannot handle them.- Each standard keeps its own way of expressing amounts (
_amountfor fungible,_idfor NFTs) instead of forcing one shape on all three.
Who may mint or burn is left to the implementer.
Sample code
ERC-20 extension with owner-only minting and holder-or-owner burning:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
interface IERC5679Ext20 {
function mint(address _to, uint256 _amount, bytes calldata _data) external;
function burn(address _from, uint256 _amount, bytes calldata _data) external;
}
contract Points is ERC20, Ownable, IERC5679Ext20 {
constructor() ERC20("Points", "PTS") Ownable(msg.sender) {}
function mint(address to, uint256 amount, bytes calldata) external onlyOwner {
_mint(to, amount); // emits Transfer(address(0), to, amount)
}
function burn(address from, uint256 amount, bytes calldata) external {
require(msg.sender == from || msg.sender == owner(), "not allowed");
_burn(from, amount); // emits Transfer(from, address(0), amount)
}
function supportsInterface(bytes4 id) external pure returns (bool) {
return id == 0xd0017968 || id == 0x01ffc9a7; // ERC-5679 (ERC-20) + ERC-165
}
}
Things to know
- Status is Final.
- Access control is the real risk. An unprotected
mintmeans anyone can inflate supply; the spec suggests burning be limited to the holder, a privileged role, or both. - Note the ERC-1155 single
burntakesbytes[] _datawhileburnBatchtakesbytes; copy the signatures exactly or the interface ID will not match. - ERC-777 is not covered because it already defines its own minting and burning.