XRP Ledger Standards
XLS-0085 Final Amendment

Token-Enabled Escrows

Enhancement to existing Escrow functionality to support both Trustline-based tokens (IOUs) and Multi-Purpose Tokens (MPTs)

Author
Denis Angell
Created
2024-11-07
Updated
2026-12-02
Requires
XLS-33
Discussion
XRPLF/XRPL-Standards/discussions/248

This proposal, XLS-85, replaces XLS-34 and draws inspiration from https://github.com/XRPLF/XRPL-Standards/discussions/133.

1. Abstract

The proposed TokenEscrow amendment to the XRP Ledger (XRPL) protocol enhances the existing Escrow functionality by enabling support for both Trustline-based tokens (IOUs) and Multi-Purpose Tokens (MPTs). This amendment introduces changes to ledger objects, transactions, and transaction processing logic to allow escrows to use IOU tokens and MPTs, while respecting issuer controls and maintaining ledger integrity.

2. Specification

This amendment extends the functionality of escrows to support both IOUs and MPTs, accounting for the specific behaviors and constraints associated with each token type. Appendix A gives an overview of the two token types.

2.1. Ledger Entry: Escrow

2.1.1. Object Identifier

The object identifier of this ledger entry does not change.

2.1.2. Fields

The Escrow ledger object is updated as follows:

Field Name Constant Required Internal Type Default Value Description
Amount TODO TODO AMOUNT N/A The amount to be delivered by the held payment. Can represent XRP, an IOU token, or an MPT. Must always be a positive value. JSON type: object or string.
TransferRate TODO TODO UINT32 N/A The transfer rate or fee at which the funds are escrowed, stored at creation and used during settlement. Applicable to both IOUs and MPTs. JSON type: number.
IssuerNode TODO No UINT64 N/A The ledger index of the issuer's directory node associated with the Escrow. Used when the issuer is neither the source nor destination account. JSON type: number.

2.1.3. Ownership

TODO: content pass.

2.1.4. Reserves

The reserves of this ledger entry do not change.

2.1.5. Deletion

TODO: content pass.

2.1.6. Invariants

TODO: content pass.

2.1.7. RPC Name

The RPC name of this ledger entry does not change.

2.1.8. Example JSON

TODO: content pass.

2.2. Ledger Entry: MPToken

2.2.1. Object Identifier

The object identifier of this ledger entry does not change.

2.2.2. Fields

The MPToken ledger object is updated as follows:

Field Name Constant Required Internal Type Default Value Description
LockedAmount TODO No UINT64 N/A The total of all outstanding escrows for this issuance. JSON type: string.

2.2.3. Ownership

The ownership of this ledger entry does not change.

2.2.4. Reserves

The reserves of this ledger entry do not change.

2.2.5. Deletion

TODO: content pass.

2.2.6. Invariants

TODO: content pass.

2.2.7. RPC Name

The RPC name of this ledger entry does not change.

2.2.8. Example JSON

TODO: content pass.

2.3. Ledger Entry: MPTokenIssuance

2.3.1. Object Identifier

The object identifier of this ledger entry does not change.

2.3.2. Fields

The MPTokenIssuance ledger object is updated as follows:

Field Name Constant Required Internal Type Default Value Description
LockedAmount TODO No UINT64 N/A The total of all outstanding escrows for this issuance. JSON type: string.

2.3.3. Ownership

The ownership of this ledger entry does not change.

2.3.4. Reserves

The reserves of this ledger entry do not change.

2.3.5. Deletion

TODO: content pass.

2.3.6. Invariants

TODO: content pass.

2.3.7. RPC Name

The RPC name of this ledger entry does not change.

2.3.8. Example JSON

TODO: content pass.

2.4. Ledger Entry: AccountRoot

2.4.1. Object Identifier

The object identifier of this ledger entry does not change.

2.4.2. Fields

The fields of this ledger entry do not change.

2.4.3. Flags

This proposal introduces 1 additional flag for the Flags field of AccountRoot:

Flag Name Flag Value Description
lsfAllowTrustLineLocking 0x40000000 Allow trust line tokens (IOUs) issued by this account to be held in escrow. Set with the asfAllowTrustLineLocking AccountSet flag.

2.4.4. Ownership

The ownership of this ledger entry does not change.

2.4.5. Reserves

The reserves of this ledger entry do not change.

2.4.6. Deletion

The deletion rules of this ledger entry do not change.

2.4.7. Invariants

The invariants of this ledger entry do not change.

2.4.8. RPC Name

The RPC name of this ledger entry does not change.

2.4.9. Example JSON

The JSON format of this ledger entry does not change.

2.5. Transaction: EscrowCreate

2.5.1. Fields

The EscrowCreate transaction is modified as follows:

Field Name Required JSON Type Internal Type Default Value Description
Amount Yes object or string AMOUNT N/A The amount to deduct from the sender's balance and set aside in escrow. Once escrowed, this amount can either go to the Destination address (after any Finish times/conditions) or returned to the sender (after any cancellation times/conditions). Can represent XRP, in drops, an IOU token, or an MPT. Must always be a positive value.

2.5.2. Transaction Fee

The fee for this transaction does not change.

2.5.3. Failure Conditions

2.5.3.1. Data Verification

TODO: content pass.

2.5.3.2. Protocol-Level Failures
  1. Issuer is the Source: The source account is the issuer of the token (tecNO_PERMISSION).
  2. Issuer Does Not Allow Token Escrow (IOU Tokens): The issuer's account does not have the lsfAllowTrustLineLocking flag set. This flag must be set by the token issuer account before any escrows can be created with their IOUs (tecNO_PERMISSION).
  3. Issuer Does Not Allow Token Escrow (MPTs): The MPTokenIssuance of the token being escrowed lacks the lsfMPTCanEscrow flag (tecNO_PERMISSION).
  4. Issuer Does Not Allow Token Transfer (MPTs): The MPTokenIssuance of the token being escrowed lacks the lsfMPTCanTransfer flag, unless the destination address of the Escrow is the issuer of the MPT (tecNO_PERMISSION).
  5. Source Account Not Authorized to Hold Token: The issuer requires authorization and the source is not authorized (tecNO_AUTH).
  6. Source Account's Token Holding Issues (IOU Tokens): The source lacks a trustline with the issuer (tecUNFUNDED).
  7. Source Account's Token Holding Issues (MPTs): The source does not hold the MPT (tecOBJECT_NOT_FOUND).
  8. Source Account is Frozen or Token is Locked: The token is frozen (global/individual/deepfreeze) (IOU) or locked (MPT) for the source (tecFROZEN).
  9. Insufficient Spendable Balance: The source account lacks sufficient spendable balance (tecUNFUNDED).

2.5.4. State Changes

  1. Adjustment from Source to Issuer (IOU Tokens): The escrow Amount is deducted from the source's trustline balance.
  2. Adjustment from Source to Issuer (MPTs): The escrow Amount is deducted from the source's MPT balance. The OutstandingAmount of the MPT issuance remains unchanged. The LockedAmount is increased on both the source's MPT and the MPT issuance.
  3. Escrow Object Creation: The Escrow ledger object includes:
    • Amount: Tokens held in escrow.
    • TransferRate: TransferRate (IOUs) or TransferFee (MPTs) at creation. The TransferRate (IOU tokens) or TransferFee (MPTs) is captured at the time of EscrowCreate and stored in the Escrow object.
    • IssuerNode: Reference to the issuer’s ledger node if applicable.

2.5.5. Example JSON

TODO: content pass.

2.6. Transaction: EscrowFinish

2.6.1. Fields

The fields of this transaction do not change.

2.6.2. Transaction Fee

The fee for this transaction does not change.

2.6.3. Failure Conditions

2.6.3.1. Data Verification

TODO: content pass.

2.6.3.2. Protocol-Level Failures
  1. Destination Not Authorized to Hold Token: Authorization is required and the destination is not authorized (tecNO_AUTH).
  2. Destination Lacks Trustline (IOU Tokens): The destination lacks a trustline with the issuer (tecNO_LINE).
  3. Destination Lacks MPT Holding (MPTs): The destination does not hold the MPT (tecNO_PERMISSION).
  4. Cannot Create Trustline or MPT Holding: Unable to create it due to lack of authorization (tecNO_AUTH).
  5. Cannot Create Trustline or MPT Holding: Unable to create it due to lack of reserves (tecINSUFFICIENT_RESERVE).
  6. Destination Account is Frozen (IOU Tokens): The token is deep frozen (tecFROZEN).
  7. Token is Locked (MPTs): The token is locked (Lock Conditions, equivalent to Deep Freeze) (tecFROZEN).

Global/Individual Freeze (IOU Tokens): The transaction succeeds despite the token being globally or individually frozen.

2.6.4. State Changes

  1. Auto create Trustline or MPToken: A new trustline or MPT holding may be created during EscrowFinish if authorization is not required.
    1. IOU Tokens: If the IOU does not require authorization and the account submitting the transaction is the recipient, then a trustline will be created.
    2. MPTs: If the MPT does not require authorization and the account submitting the transaction is the recipient, then the MPT will be created.
  2. Adjustment from Issuer to Destination (IOU Tokens): The escrow Amount is added to the destination's trustline balance.
  3. Adjustment from Issuer to Destination (MPTs):
    1. If the escrow sender is the issuer of the asset that was escrowed and the destination is not the issuer, then:
      1. The LockedAmount on the MPTokenIssuance of the asset that was held in escrow is decreased by Amount.
      2. The Amount on the destination's MPToken is increased by the escrow's Amount.
      3. The OutstandingAmount on the MPTokenIssuance of the asset that was held in escrow is unchanged.
    2. If the escrow sender is not the issuer of the asset that was escrowed but the destination is the issuer of the asset, then:
      1. The LockedAmount on the MPTokenIssuance of the asset that was held in escrow is decreased by Amount.
      2. No MPToken objects are changed because MPT issuers may not hold MPTokens.
      3. The OutstandingAmount on the MPTokenIssuance of the asset that was held in escrow is decreased by Amount (i.e., this escrow finish is a "redemption").
    3. If neither the escrow source nor destination is the issuer of the asset that was escrowed, then
      1. The LockedAmount on the MPTokenIssuance of the asset that was held in escrow is decreased by the escrow Amount.
      2. The LockedAmount on the source's MPToken is decreased by the escrow Amount.
      3. The Amount on the destination's MPToken is increased by the escrow Amount.
      4. The OutstandingAmount on the MPTokenIssuance of the asset that was held in escrow is unchanged.
  4. Transfer Rates and Fees:
    1. Locked Transfer Rate (IOU Tokens): The TransferRate stored in the Escrow object is used during EscrowFinish, even if the issuer changes it later. The escrowed amount is adjusted according to the TransferRate upon settlement, potentially reducing the final amount credited to the destination.
    2. Locked Transfer Fee (MPTs): The TransferFee stored in the Escrow object, similar to IOUs, is used during settlement. The escrowed amount is adjusted according to the TransferFee upon settlement, potentially reducing the final amount credited to the destination.
  5. Deletion of Escrow Object: The Escrow object is deleted after successful settlement.

2.6.5. Example JSON

The JSON format of this transaction does not change.

2.7. Transaction: EscrowCancel

2.7.1. Fields

The fields of this transaction do not change.

2.7.2. Transaction Fee

The fee for this transaction does not change.

2.7.3. Failure Conditions

2.7.3.1. Data Verification

TODO: content pass.

2.7.3.2. Protocol-Level Failures
  1. Source Not Authorized to Hold Token: Authorization is required and the source is not authorized (tecNO_AUTH).
  2. Source Lacks Trustline (IOU Tokens): The source lacks a trustline with the issuer (tecNO_LINE).
  3. Source Lacks MPT Holding (MPTs): The source does not hold the MPT (tecNO_PERMISSION).
  4. Cannot Create Trustline or MPT Holding: Unable to create it due to lack of authorization (tecNO_AUTH).
  5. Cannot Create Trustline or MPT Holding: Unable to create it due to lack of reserves (tecINSUFFICIENT_RESERVE).

Source Account is Frozen or Token is Locked: The transaction succeeds, allowing the escrow to be canceled, in each of these cases: IOU Tokens with Deep Freeze, IOU Tokens with Global/Individual Freeze, and MPTs with Lock Conditions (Deep Freeze Equivalent).

2.7.4. State Changes

  1. Auto create Trustline or MPToken: A new trustline or MPT holding may be created during EscrowCancel if authorization is not required.
    1. IOU Tokens: If the IOU does not require authorization and the account submitting the transaction is the recipient, then a trustline will be created.
    2. MPTs: If the MPT does not require authorization and the account submitting the transaction is the recipient, then the MPT will be created.
  2. Adjustment from Issuer to Source (IOU Tokens): The escrow Amount is added to the source's trustline balance.
  3. Adjustment from Issuer to Source (MPTs): The escrow Amount is added to the source's MPT balance. The OutstandingAmount of the MPT issuance remains unchanged. The LockedAmount is decreased on both the source's MPT and the MPT issuance.
  4. Deletion of Escrow Object: The Escrow object is deleted after successful cancellation.

2.7.5. Example JSON

The JSON format of this transaction does not change.

2.8. Transaction: AccountSet

To enable IOU tokens to be held in escrow, issuers must set the lsfAllowTrustLineLocking flag on their account. This is done using the AccountSet transaction with the new asfAllowTrustLineLocking flag.

2.8.1. Fields

The fields of this transaction do not change.

2.8.2. Flags

The following AccountSet flag is added to enable trust line locking for escrows:

Flag Name Flag Value Description
asfAllowTrustLineLocking 17 Allow trust line tokens (IOUs) issued by this account to be held in escrow. (Requires the TokenEscrow amendment.) Can only be enabled by the issuer account. Once enabled, holders of this account's issued tokens can create escrows with those tokens.

2.8.3. Transaction Fee

The fee for this transaction does not change.

2.8.4. Failure Conditions

TODO: content pass.

2.8.5. State Changes

  1. With SetFlag set to asfAllowTrustLineLocking, the lsfAllowTrustLineLocking flag is set on the account. The flag applies only to IOU tokens (trust line based tokens). For MPTs, escrow permissions are controlled by the tfMPTCanEscrow flag on the MPTokenIssuance object.

2.8.6. Example JSON

To enable trust line locking for an issuer account:

{
  "TransactionType": "AccountSet",
  "Account": "rIssuerAccountAddress...",
  "SetFlag": 17,
  "Fee": "12",
  "Sequence": 5
}

3. Rationale

TODO: content pass.

3.1. Consistent Fee Application

Both IOUs and MPTs use the transfer rate or fee stored at escrow creation, ensuring predictability for the destination.

3.2. Future Considerations

  1. Clawback: XLS-85 currently does not provide a direct “clawback” mechanism within an active Escrow. If your use case requires clawback, you can either finish or cancel the Escrow (as appropriate) and then perform a clawback of the funds outside of the Escrow context. In other words, once the token amount returns to the issuer or source account, the existing clawback features for IOUs or MPTs can be used on those returned funds.

  2. Issuer as Source: XLS-85 currently does not allow the issuer to be the source of the Escrow. If your use case requires this functionality, you should create a new account, send the MPT or IOU to that account, and then Escrow the token.

4. Security Considerations

TODO: content pass.

Appendix

Appendix A: Overview of Token Types

A.1: IOU Tokens

  • Trustlines: IOUs rely on trustlines between accounts.
  • Issuer Controls:
    • Require Authorization (lsfRequireAuth): Issuers may require accounts to be authorized to hold their tokens.
    • Freeze Conditions (lsfGlobalFreeze, lsfDefaultRipple): Issuers can freeze tokens, affecting their transferability.
  • Transfer Mechanics: Transfers occur via adjustments to trustline balances.
  • Transfer Rates: Issuers can set a TransferRate that affects transfers involving their tokens.

A.2: Multi-Purpose Tokens (MPTs)

  • No Trustlines: MPTs do not utilize trustlines.
  • Issuer Controls:
    • Transfer Flags (tfMPTCanTransfer): Tokens must have this flag enabled to be transferable and to participate in transactions like escrows.
    • Require Authorization (tfMPTRequireAuth): Issuers may require authorization for accounts to hold their tokens.
    • Lock Conditions (lsfMPTokenLock): Tokens can be locked by the issuer, affecting their transferability.
  • Transfer Mechanics: Transfers occur by moving token balances directly between accounts.
  • Transfer Fees: Issuers can set a TransferFee (analogous to TransferRate for IOUs) that affects transfers involving their tokens.

Appendix B: Key Differences Between IOU and MPT Escrows

Aspect IOU Tokens Multi-Purpose Tokens (MPTs)
Trustlines Required between accounts and issuer Not used
Issuer Flag for Escrow lsfAllowTrustLineLocking (account flag) tfMPTCanEscrow (token flag)
Transfer Flags N/A tfMPTCanTransfer must be enabled for escrow
Require Auth Applicable (lsfRequireAuth); accounts must be authorized prior to holding tokens Applicable (tfMPTRequireAuth); accounts must be authorized prior to holding tokens
Destination Authorization Not required at creation; required at settlement; cannot be granted during EscrowFinish if authorization required Not required at creation; required at settlement; cannot be granted during EscrowFinish if authorization required
Freeze/Lock Conditions Deep Freeze prevents EscrowFinish, but allows EscrowCancel; Global/Individual Freeze allows both operations Lock Conditions (Deep Freeze Equivalent) prevent EscrowFinish, but allow EscrowCancel
Transfer Rates/Fees TransferRate stored at creation and applied during settlement TransferFee stored at creation and applied during settlement
Outstanding Amount Remains unchanged during escrow Remains unchanged during escrow
Account Deletion Escrows prevent account deletion Escrows prevent account deletion