pub fn encode_peer_to_peer_by_signers_script_function(
currency: TypeTag,
amount: u64,
metadata: Vec<u8>
) -> TransactionPayloadExpand 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::SentPaymentEventonpayer’sDiemAccount::DiemAccountsent_eventshandle; and - A
DiemAccount::ReceivedPaymentEventonpayee’sDiemAccount::DiemAccountreceived_eventshandle.
Parameters
| Name | Type | Description |
|---|---|---|
Currency | Type | The Move type for the Currency being sent in this transaction. Currency must be an already-registered currency on-chain. |
payer | signer | The signer of the sending account that coins are being transferred from. |
payee | signer | The signer of the receiving account that the coins are being transferred to. |
metadata | vector<u8> | Optional metadata about this payment. |
Common Abort Conditions
| Error Category | Error Reason | Description |
|---|---|---|
Errors::NOT_PUBLISHED | DiemAccount::EPAYER_DOESNT_HOLD_CURRENCY | payer doesn’t hold a balance in Currency. |
Errors::LIMIT_EXCEEDED | DiemAccount::EINSUFFICIENT_BALANCE | amount is greater than payer’s balance in Currency. |
Errors::INVALID_ARGUMENT | DiemAccount::ECOIN_DEPOSIT_IS_ZERO | amount is zero. |
Errors::NOT_PUBLISHED | DiemAccount::EPAYEE_DOES_NOT_EXIST | No account exists at the payee address. |
Errors::INVALID_ARGUMENT | DiemAccount::EPAYEE_CANT_ACCEPT_CURRENCY_TYPE | An account exists at payee, but it does not accept payments in Currency. |
Errors::INVALID_STATE | AccountFreezing::EACCOUNT_FROZEN | The payee account is frozen. |
Errors::LIMIT_EXCEEDED | DiemAccount::EWITHDRAWAL_EXCEEDS_LIMITS | payer has exceeded its daily withdrawal limits for the backing coins of XDX. |
Errors::LIMIT_EXCEEDED | DiemAccount::EDEPOSIT_EXCEEDS_LIMITS | payee has exceeded its daily deposit limits for XDX. |
Related Scripts
AccountCreationScripts::create_child_vasp_accountAccountCreationScripts::create_parent_vasp_accountAccountAdministrationScripts::add_currency_to_accountPaymentScripts::peer_to_peer_with_metadata