pub fn encode_tiered_mint_script(
    coin_type: TypeTag,
    sliding_nonce: u64,
    designated_dealer_address: AccountAddress,
    mint_amount: u64,
    tier_index: u64
) -> Script
Expand description

Summary

Mints a specified number of coins in a currency to a Designated Dealer. The sending account must be the Treasury Compliance account, and coins can only be minted to a Designated Dealer account.

Technical Description

Mints mint_amount of coins in the CoinType currency to Designated Dealer account at designated_dealer_address. The tier_index parameter specifies which tier should be used to check verify the off-chain approval policy, and is based in part on the on-chain tier values for the specific Designated Dealer, and the number of CoinType coins that have been minted to the dealer over the past 24 hours. Every Designated Dealer has 4 tiers for each currency that they support. The sending tc_account must be the Treasury Compliance account, and the receiver an authorized Designated Dealer account.

Events

Successful execution of the transaction will emit two events:

  • A Diem::MintEvent with the amount and currency code minted is emitted on the mint_event_handle in the stored Diem::CurrencyInfo<CoinType> resource stored under 0xA550C18; and
  • A DesignatedDealer::ReceivedMintEvent with the amount, currency code, and Designated Dealer’s address is emitted on the mint_event_handle in the stored DesignatedDealer::Dealer resource published under the designated_dealer_address.

Parameters

NameTypeDescription
CoinTypeTypeThe Move type for the CoinType being minted. CoinType must be an already-registered currency on-chain.
tc_account&signerThe signer reference of the sending account of this transaction. Must be the Treasury Compliance account.
sliding_nonceu64The sliding_nonce (see: SlidingNonce) to be used for this transaction.
designated_dealer_addressaddressThe address of the Designated Dealer account being minted to.
mint_amountu64The number of coins to be minted.
tier_indexu64The mint tier index to use for the Designated Dealer account.

Common Abort Conditions

Error CategoryError ReasonDescription
Errors::NOT_PUBLISHEDSlidingNonce::ESLIDING_NONCEA SlidingNonce resource is not published under tc_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_ADDRESSCoreAddresses::ETREASURY_COMPLIANCEtc_account is not the Treasury Compliance account.
Errors::REQUIRES_ROLERoles::ETREASURY_COMPLIANCEtc_account is not the Treasury Compliance account.
Errors::INVALID_ARGUMENTDesignatedDealer::EINVALID_MINT_AMOUNTmint_amount is zero.
Errors::NOT_PUBLISHEDDesignatedDealer::EDEALERDesignatedDealer::Dealer or DesignatedDealer::TierInfo<CoinType> resource does not exist at designated_dealer_address.
Errors::INVALID_ARGUMENTDesignatedDealer::EINVALID_TIER_INDEXThe tier_index is out of bounds.
Errors::INVALID_ARGUMENTDesignatedDealer::EINVALID_AMOUNT_FOR_TIERmint_amount exceeds the maximum allowed amount for tier_index.
Errors::REQUIRES_CAPABILITYDiem::EMINT_CAPABILITYtc_account does not have a Diem::MintCapability<CoinType> resource published under it.
Errors::INVALID_STATEDiem::EMINTING_NOT_ALLOWEDMinting is not currently allowed for CoinType coins.
Errors::LIMIT_EXCEEDEDDiemAccount::EDEPOSIT_EXCEEDS_LIMITSThe depositing of the funds would exceed the account’s account limits.
  • Script::create_designated_dealer
  • Script::peer_to_peer_with_metadata
  • Script::rotate_dual_attestation_info