pub fn encode_burn_script(
    token: TypeTag,
    sliding_nonce: u64,
    preburn_address: AccountAddress
) -> Script
Expand description

Summary

Burns all coins held in the preburn resource at the specified preburn address and removes them from the system. The sending account must be the Treasury Compliance account. The account that holds the preburn resource will normally be a Designated Dealer, but there are no enforced requirements that it be one.

Technical Description

This transaction permanently destroys all the coins of Token type stored in the Diem::Preburn<Token> resource published under the preburn_address account address.

This transaction will only succeed if the sending account has a Diem::BurnCapability<Token>, and a Diem::Preburn<Token> resource exists under preburn_address, with a non-zero to_burn field. After the successful execution of this transaction the total_value field in the Diem::CurrencyInfo<Token> resource published under 0xA550C18 will be decremented by the value of the to_burn field of the preburn resource under preburn_address immediately before this transaction, and the to_burn field of the preburn resource will have a zero value.

Events

The successful execution of this transaction will emit a Diem::BurnEvent on the event handle held in the Diem::CurrencyInfo<Token> resource’s burn_events published under 0xA550C18.

Parameters

NameTypeDescription
TokenTypeThe Move type for the Token currency being burned. Token must be an already-registered currency on-chain.
tc_account&signerThe signer reference of the sending account of this transaction, must have a burn capability for Token published under it.
sliding_nonceu64The sliding_nonce (see: SlidingNonce) to be used for this transaction.
preburn_addressaddressThe address where the coins to-be-burned are currently held.

Common Abort Conditions

Error CategoryError ReasonDescription
Errors::NOT_PUBLISHEDSlidingNonce::ESLIDING_NONCEA SlidingNonce resource is not published under account.
Errors::INVALID_ARGUMENTSlidingNonce::ENONCE_TOO_OLDThe sliding_nonce is too old and it’s impossible to determine if it’s duplicated or not.
Errors::INVALID_ARGUMENTSlidingNonce::ENONCE_TOO_NEWThe sliding_nonce is too far in the future.
Errors::INVALID_ARGUMENTSlidingNonce::ENONCE_ALREADY_RECORDEDThe sliding_nonce has been previously recorded.
Errors::REQUIRES_CAPABILITYDiem::EBURN_CAPABILITYThe sending account does not have a Diem::BurnCapability<Token> published under it.
Errors::NOT_PUBLISHEDDiem::EPREBURNThe account at preburn_address does not have a Diem::Preburn<Token> resource published under it.
Errors::INVALID_STATEDiem::EPREBURN_EMPTYThe Diem::Preburn<Token> resource is empty (has a value of 0).
Errors::NOT_PUBLISHEDDiem::ECURRENCY_INFOThe specified Token is not a registered currency on-chain.
  • Script::burn_txn_fees
  • Script::cancel_burn
  • Script::preburn