Function diem_sdk::transaction_builder::stdlib::encode_preburn_script
pub fn encode_preburn_script(token: TypeTag, amount: u64) -> Script
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
onaccount
’sDiemAccount::DiemAccount
sent_events
handle with thepayee
andpayer
fields beingaccount
’s address; and- A
Diem::PreburnEvent
withToken
’s currency code on theDiem::CurrencyInfo<Token
’spreburn_events
handle forToken
and withpreburn_address
set toaccount
’s address.
Parameters
Name | Type | Description |
---|---|---|
Token | Type | The Move type for the Token currency being moved to the preburn area. Token must be an already-registered currency on-chain. |
account | &signer | The signer reference of the sending account. |
amount | u64 | The amount in Token to be moved to the preburn area. |
Common Abort Conditions
Error Category | Error Reason | Description |
---|---|---|
Errors::NOT_PUBLISHED | Diem::ECURRENCY_INFO | The Token is not a registered currency on-chain. |
Errors::INVALID_STATE | DiemAccount::EWITHDRAWAL_CAPABILITY_ALREADY_EXTRACTED | The withdrawal capability for account has already been extracted. |
Errors::LIMIT_EXCEEDED | DiemAccount::EINSUFFICIENT_BALANCE | amount is greater than payer ’s balance in Token . |
Errors::NOT_PUBLISHED | DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY | account doesn’t hold a balance in Token . |
Errors::NOT_PUBLISHED | Diem::EPREBURN | account doesn’t have a Diem::Preburn<Token> resource published under it. |
Errors::INVALID_STATE | Diem::EPREBURN_OCCUPIED | The value field in the Diem::Preburn<Token> resource under the sender is non-zero. |
Errors::NOT_PUBLISHED | Roles::EROLE_ID | The account did not have a role assigned to it. |
Errors::REQUIRES_ROLE | Roles::EDESIGNATED_DEALER | The account did not have the role of DesignatedDealer. |
Related Scripts
Script::cancel_burn
Script::burn
Script::burn_txn_fees