Contract-Design

是否有允許未來鑄造和銷毀代幣的代幣標準?

  • June 23, 2019

我對一種乙太坊代幣感興趣,該代幣具有讓運營商隨時鑄造新供應的功能。如果運營商可以明確地銷毀供應而不是發送到某個地址,那也很好。這種代幣有標準嗎?

ERC777提供了鑄造和銷毀代幣的指南。以下是 ERC777 的摘錄:

鑄造代幣

Minting tokens is the act of producing new tokens.
[ERC777] intentionally does not define specific functions to mint tokens.
This intent comes from the wish not to limit the use of the [ERC777] standard
as the minting process is generally specific for every token.

Nonetheless, the rules below MUST be respected when minting for a *recipient*:

- Tokens MAY be minted for any *recipient* address (except `0x0`).

- The total supply MUST be increased by the amount of tokens minted.

- The balance of `0x0` MUST NOT be decreased.

- The balance of the *recipient* MUST be increased by the amount of tokens minted.

- The token contract MUST emit a `Minted` event with the correct values as defined in the [`Minted` Event][minted].

- The token contract MUST call the `tokensReceived` hook of the *recipient*
 if the *recipient* registers an `ERC777TokensRecipient` implementation via [ERC1820].

- The `data` and `operatorData` MUST be immutable during the entire mint process -- hence the same `data` and `operatorData` MUST be used to call the `tokensReceived` hook and emit the `Minted` event.

燃燒代幣

Burning tokens is the act of destroying existing tokens.
[ERC777] explicitly defines two functions to burn tokens (`burn` and `operatorBurn`).
These functions facilitate the integration of the burning process in wallets and dapps.
However, the token contract MAY prevent some or all *holders* from burning tokens for any reason.
The token contract MAY also define other functions to burn tokens.

The rules below MUST be respected when burning the tokens of a *holder*:

- Tokens MAY be burned from any *holder* address (except `0x0`).

- The total supply MUST be decreased by the amount of tokens burned.

- The balance of `0x0` MUST NOT be increased.

- The balance of the *holder* MUST be decreased by amount of tokens burned.

- The token contract MUST emit a `Burned` event with the correct values as defined in the [`Burned` Event][burned].

- The token contract MUST call the `tokensToSend` hook of the *holder*
 if the *holder* registers an `ERC777TokensSender` implementation via [ERC1820].

- The `operatorData` MUST be immutable during the entire burn process—hence
 the same `operatorData` MUST be used to call the `tokensToSend` hook and emit the `Burned` event.

The token contract MUST `revert` when burning in any of the following cases:

- The *operator* address is not an authorized operator for the *holder*.

- The resulting *holder* balance after the burn is not a multiple of the *granularity*
 defined by the token contract.

- The balance of *holder* is inferior to the amount of tokens to burn
 (i.e., resulting in a negative balance for the *holder*).

- The address of the *holder* is `0x0`.

- The `tokensToSend` hook of the *holder* `revert`s.

ERC777 鼓勵與 ERC20 兼容。在ERC777 的全文中指定了鑄造和燃燒的額外要求,這些要求已從本答案中省略。

引用自:https://ethereum.stackexchange.com/questions/72137