pub fn encode_cancel_burn_with_amount_script_function(
token: TypeTag,
preburn_address: AccountAddress,
amount: u64
) -> TransactionPayloadExpand description
Summary
Cancels and returns the coins held in the preburn area under
preburn_address, which are equal to the amount specified in the transaction. Finds the first preburn
resource with the matching amount 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::CancelBurnEventon the event handle held in theDiem::CurrencyInfo<Token>resource’sburn_eventspublished under0xA550C18. - A
DiemAccount::ReceivedPaymentEventon thepreburn_address’sDiemAccount::DiemAccountreceived_eventsevent handle with both thepayerandpayeebeingpreburn_address.
Parameters
| Name | Type | Description |
|---|---|---|
Token | Type | The Move type for the Token currenty that burning is being cancelled for. Token must be an already-registered currency on-chain. |
account | signer | The signer of the sending account of this transaction, must have a burn capability for Token published under it. |
preburn_address | address | The address where the coins to-be-burned are currently held. |
amount | u64 | The amount to be cancelled. |
Common Abort Conditions
| Error Category | Error Reason | Description |
|---|---|---|
Errors::REQUIRES_CAPABILITY | Diem::EBURN_CAPABILITY | The sending account does not have a Diem::BurnCapability<Token> published under it. |
Errors::INVALID_STATE | Diem::EPREBURN_NOT_FOUND | The Diem::PreburnQueue<Token> resource under preburn_address does not contain a preburn request with a value matching amount. |
Errors::NOT_PUBLISHED | Diem::EPREBURN_QUEUE | The account at preburn_address does not have a Diem::PreburnQueue<Token> resource published under it. |
Errors::NOT_PUBLISHED | Diem::ECURRENCY_INFO | The specified Token is not a registered currency on-chain. |
Errors::INVALID_ARGUMENT | DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE | The account at preburn_address doesn’t have a balance resource for Token. |
Errors::LIMIT_EXCEEDED | DiemAccount::EDEPOSIT_EXCEEDS_LIMITS | The depositing of the funds held in the prebun area would exceed the account’s account limits. |
Errors::INVALID_STATE | DualAttestation::EPAYEE_COMPLIANCE_KEY_NOT_SET | The account does not have a compliance key set on it but dual attestion checking was performed. |
Related Scripts
TreasuryComplianceScripts::burn_txn_feesTreasuryComplianceScripts::burn_with_amountTreasuryComplianceScripts::preburn