pub fn encode_preburn_script_function(
    token: TypeTag,
    amount: u64
) -> TransactionPayload
Expand description

Summary

Moves a specified number of coins in a given currency from the account’s balance to its preburn area after which the coins may be burned. This transaction may be sent by any account that holds a balance and preburn area in the specified currency.

Technical Description

Moves the specified amount of coins in Token currency from the sending account’s DiemAccount::Balance<Token> to the Diem::Preburn<Token> published under the same account. account must have both of these resources published under it at the start of this transaction in order for it to execute successfully.

Events

Successful execution of this script emits two events:

  • DiemAccount::SentPaymentEvent on account’s DiemAccount::DiemAccount sent_events handle with the payee and payer fields being account’s address; and
  • A Diem::PreburnEvent with Token’s currency code on the Diem::CurrencyInfo<Token’s preburn_events handle for Token and with preburn_address set to account’s address.

Parameters

NameTypeDescription
TokenTypeThe Move type for the Token currency being moved to the preburn area. Token must be an already-registered currency on-chain.
accountsignerThe signer of the sending account.
amountu64The amount in Token to be moved to the preburn area.

Common Abort Conditions

Error CategoryError ReasonDescription
Errors::NOT_PUBLISHEDDiem::ECURRENCY_INFOThe Token is not a registered currency on-chain.
Errors::INVALID_STATEDiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTEDThe withdrawal capability for account has already been extracted.
Errors::LIMIT_EXCEEDEDDiemAccount::EINSUFFICIENT_BALANCEamount is greater than payer’s balance in Token.
Errors::NOT_PUBLISHEDDiemAccount::EPAYER_DOESNT_HOLD_CURRENCYaccount doesn’t hold a balance in Token.
Errors::NOT_PUBLISHEDDiem::EPREBURNaccount doesn’t have a Diem::Preburn<Token> resource published under it.
Errors::INVALID_STATEDiem::EPREBURN_OCCUPIEDThe value field in the Diem::Preburn<Token> resource under the sender is non-zero.
Errors::NOT_PUBLISHEDRoles::EROLE_IDThe account did not have a role assigned to it.
Errors::REQUIRES_ROLERoles::EDESIGNATED_DEALERThe account did not have the role of DesignatedDealer.
  • TreasuryComplianceScripts::cancel_burn_with_amount
  • TreasuryComplianceScripts::burn_with_amount
  • TreasuryComplianceScripts::burn_txn_fees