pub fn encode_peer_to_peer_by_signers_script_function(
    currency: TypeTag,
    amount: u64,
    metadata: Vec<u8>
) -> TransactionPayload
Expand description

Summary

Transfers a given number of coins in a specified currency from one account to another by multi-agent transaction. Transfers over a specified amount defined on-chain that are between two different VASPs, or other accounts that have opted-in will be subject to on-chain checks to ensure the receiver has agreed to receive the coins. This transaction can be sent by any account that can hold a balance, and to any account that can hold a balance. Both accounts must hold balances in the currency being transacted.

Technical Description

Transfers amount coins of type Currency from payer to payee with (optional) associated metadata. Dual attestation is not applied to this script as payee is also a signer of the transaction. Standardized metadata BCS format can be found in diem_types::transaction::metadata::Metadata.

Events

Successful execution of this script emits two events:

  • A DiemAccount::SentPaymentEvent on payer’s DiemAccount::DiemAccount sent_events handle; and
  • A DiemAccount::ReceivedPaymentEvent on payee’s DiemAccount::DiemAccount received_events handle.

Parameters

NameTypeDescription
CurrencyTypeThe Move type for the Currency being sent in this transaction. Currency must be an already-registered currency on-chain.
payersignerThe signer of the sending account that coins are being transferred from.
payeesignerThe signer of the receiving account that the coins are being transferred to.
metadatavector<u8>Optional metadata about this payment.

Common Abort Conditions

Error CategoryError ReasonDescription
Errors::NOT_PUBLISHEDDiemAccount::EPAYER_DOESNT_HOLD_CURRENCYpayer doesn’t hold a balance in Currency.
Errors::LIMIT_EXCEEDEDDiemAccount::EINSUFFICIENT_BALANCEamount is greater than payer’s balance in Currency.
Errors::INVALID_ARGUMENTDiemAccount::ECOIN_DEPOSIT_IS_ZEROamount is zero.
Errors::NOT_PUBLISHEDDiemAccount::EPAYEE_DOES_NOT_EXISTNo account exists at the payee address.
Errors::INVALID_ARGUMENTDiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPEAn account exists at payee, but it does not accept payments in Currency.
Errors::INVALID_STATEAccountFreezing::EACCOUNT_FROZENThe payee account is frozen.
Errors::LIMIT_EXCEEDEDDiemAccount::EWITHDRAWAL_EXCEEDS_LIMITSpayer has exceeded its daily withdrawal limits for the backing coins of XDX.
Errors::LIMIT_EXCEEDEDDiemAccount::EDEPOSIT_EXCEEDS_LIMITSpayee has exceeded its daily deposit limits for XDX.
  • AccountCreationScripts::create_child_vasp_account
  • AccountCreationScripts::create_parent_vasp_account
  • AccountAdministrationScripts::add_currency_to_account
  • PaymentScripts::peer_to_peer_with_metadata