pub fn encode_cancel_burn_script(
    token: TypeTag,
    preburn_address: AccountAddress
) -> Script
Expand description

Summary

Cancels and returns all coins held in the preburn area under preburn_address and returns the funds to the preburn_address’s balance. Can only be successfully sent by an account with Treasury Compliance role.

Technical Description

Cancels and returns all coins held in the Diem::Preburn<Token> resource under the preburn_address and return the funds to the preburn_address account’s DiemAccount::Balance<Token>. The transaction must be sent by an account with a Diem::BurnCapability<Token> resource published under it. The account at preburn_address must have a Diem::Preburn<Token> resource published under it, and its value must be nonzero. The transaction removes the entire balance held in the Diem::Preburn<Token> resource, and returns it back to the account’s DiemAccount::Balance<Token> under preburn_address. Due to this, the account at preburn_address must already have a balance in the Token currency published before this script is called otherwise the transaction will fail.

Events

The successful execution of this transaction will emit:

  • A Diem::CancelBurnEvent on the event handle held in the Diem::CurrencyInfo<Token> resource’s burn_events published under 0xA550C18.
  • A DiemAccount::ReceivedPaymentEvent on the preburn_address’s DiemAccount::DiemAccount received_events event handle with both the payer and payee being preburn_address.

Parameters

NameTypeDescription
TokenTypeThe Move type for the Token currenty that burning is being cancelled for. Token must be an already-registered currency on-chain.
account&signerThe signer reference of the sending account of this transaction, must have a burn capability for Token published under it.
preburn_addressaddressThe address where the coins to-be-burned are currently held.

Common Abort Conditions

Error CategoryError ReasonDescription
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::NOT_PUBLISHEDDiem::ECURRENCY_INFOThe specified Token is not a registered currency on-chain.
Errors::INVALID_ARGUMENTDiemAccount::ECOIN_DEPOSIT_IS_ZEROThe value held in the preburn resource was zero.
Errors::INVALID_ARGUMENTDiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPEThe account at preburn_address doesn’t have a balance resource for Token.
Errors::LIMIT_EXCEEDEDDiemAccount::EDEPOSIT_EXCEEDS_LIMITSThe depositing of the funds held in the prebun area would exceed the account’s account limits.
Errors::INVALID_STATEDualAttestation::EPAYEE_COMPLIANCE_KEY_NOT_SETThe account does not have a compliance key set on it but dual attestion checking was performed.
  • Script::burn_txn_fees
  • Script::burn
  • Script::preburn