Amendment XLS: Smart MPTs #425
mvadari
started this conversation in
XLS Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Smart MPTs
1. Abstract
This proposal introduces a new Smart Feature that allows Multi-Purpose Tokens to have custom rules, or Transfer Conditions, that must be met before they can be transferred.
The core of the system is a piece of custom WebAssembly code called a Transfer Function, which is attached to the token when it is first issued. When someone attempts a payment (or any other transfer of funds, such as a Check or Escrow), this code automatically runs a quick check (by running the Transfer Function) to determine if the transfer is permitted. If the check returns a "no," the transaction fails immediately.
2. Motivation
Regulated financial assets require a robust compliance framework on-chain to enable regulated participants to meet real-world regulatory requirements. Issuers of tokenized assets, or regulated institutions acting on their behalf, must have mechanisms in place to enforce transaction restrictions, track ownership, and apply necessary approvals for secondary transfers between two investors.
Some example use cases:
3. Overview
This design follows the lead of Smart Escrows and reuses many of the design paradigms established in that specification. This spec proposes:
MPTokenIssuanceandMPTokenledger entriesMPTokenIssuanceCreate,MPTokenIssuanceSet,Payment,EscrowFinish,ConfidentialSend,PaymentChannelClaim, andCheckCashtransactionsThis feature will require an amendment, tentatively titled
SmartMPToken.This spec does not currently allow tokens with a transfer condition to be traded on the DEX.
Note: this spec assumes XLS-94 (Dynamic MPTs) and Confidential MPTs will both be implemented before this.
4. Ledger Entry:
MPTokenIssuance4.1. Fields
As a reference, here are the existing fields for the
MPTokenIssuanceledger entry.IssuerAssetScale0, meaning that the MPT cannot be divided into smaller than 1 unit.MaximumAmountOutstandingAmountLockedAmountOutstandingAmount.TransferFeeTransferFeeof 50,000 corresponds to 50%. The default value for this field is 0. Any decimals in the transfer fee are rounded down. The fee can be rounded down to zero if the payment is small. Issuers should make sure that their MPT'sAssetScaleis large enough.MPTokenMetadataOwnerNodePreviousTxnIDPreviousTxnLgrSeqSequenceSequence(orTicket) number of the transaction that created this issuance. This helps to uniquely identify the issuance and distinguish it from any other later MPT issuances created by this account.The existing fields still exist as-is. These fields are proposed as an addition:
TransferFunctionstringBlobDatastringBlobTransferFunction.4.1.1.
TransferFunctionThe compiled WASM code included in this field must contain a function named
transferthat takes no parameters and returns a signed integer (int32). If the function returns a value greater than 0, the transfer is allowed. If the function returns 0 or a negative number, the transfer is disallowed.The function is triggered on every MPT transfer transaction that involves this MPT issuance.
See XLS-102 for detailed specifications of each host function and their gas costs.
4.2. Reserves
An
MPTokenIssuanceobject with aTransferFunctionwill cost 1 additional object reserve per 500 bytes (beyond the first 500 bytes, which are included in the first object reserve).5. Ledger Entry:
MPToken5.1. Fields
As a reference, here are the existing fields for the
MPTokenledger entry.AccountMPTokenIssuanceIDMPTokenIssuanceidentifier.MPTAmountLockedAmountPreviousTxnIDPreviousTxnLgrSeqOwnerNodeThe existing fields still exist as-is. These fields are proposed as an addition:
DatastringBlobTransferFunction.6. Transaction:
MPTokenIssuanceCreate6.1. Fields
As a reference, here are the existing fields for the
MPTokenIssuanceCreatetransaction.AssetScaleTransferFeeMaximumAmountMPTokenMetadataMutableFlagsMutableFlagsindicate specific fields or flags may be modified after issuance. Introduced in XLS-94.The existing fields still exist as-is, with
MutableFlagshaving some additional possible values. These fields are proposed as an addition:TransferFunctionstringBlobDatastringBlobTransferFunction.6.1.1. Mutable Flags
Mutable flags are proposed in XLS-94. These are the current valid values:
0x00000001Flagsvalues, theMutableFlagsvalue starts from0x00000002.]tmfMPTCanMutateCanLock0x00000002lsfMPTCanLockcan be changedtmfMPTCanMutateRequireAuth0x00000004lsfMPTRequireAuthcan be changedtmfMPTCanMutateCanEscrow0x00000008lsfMPTCanEscrowcan be changedtmfMPTCanMutateCanTrade0x00000010lsfMPTCanTradecan be changedtmfMPTCanMutateCanTransfer0x00000020lsfMPTCanTransfercan be changedtmfMPTCanMutateCanClawback0x00000040lsfMPTCanClawbackcan be changedtmfMPTCanMutateMetadata0x00010000MPTokenMetadatato be modifiedtmfMPTCanMutateTransferFee0x00020000TransferFeeto be modifiedThis spec proposes the following additions:
tmfMPTCanMutateTransferFunction0x00040000TransferFunctionto be modifiedtmfMPTCanMutateData0x00080000Datato be modified6.2. Transaction Fee
An$base_fee * 10$ ) + 5 drops per byte in the
MPTokenIssuanceCreatetransaction with aTransferFunctioncosts an additional 100 drops (TransferFunction.6.3. Failure Conditions
The existing failure conditions are still included, plus:
TransferFunctionis not valid WASM code or is invalid in some other way (e.g., using a nonexistent host function).TransferFunctiondoes not abide by the ABI (must have atransfer()function that takes no parameters and returns i32).TransferFunctionexceeds the size limit (100 KB, as specified in FeeSettings).Datafield length exceeds the size limit (4 KB, as specified in FeeSettings).TransferFunctionis included, buttfMPTCanTransferis not.TransferFunctionandtfMPTCanTradeare both included.6.4. State Changes
If the transaction is successful:
MPTokenIssuanceobject is created as normal, with theTransferFunctionandDatafields, if applicable.7. Transaction:
MPTokenIssuanceSet7.1. Fields
As a reference, here are the existing fields for the
MPTokenIssuanceSettransaction, with XLS-94 in effect.MPTokenIssuanceIDMPTokenIssuanceto update.HolderMPTokenMetadatastringlsmfMPTCanMutateMetadatawas not set inMutableFlags. Setting an emptyMPTokenMetadataremoves the field.TransferFeenumberlsmfMPTCanMutateTransferFeewas not set inMutableFlags. SettingTransferFeeto zero removes the field.MutableFlagsnumberThe existing fields still exist as-is. These fields are proposed as additions:
TransferFunctionstringBloblsmfTransferFunctionMutableflag set. Setting an emptyTransferFunctionremoves the field.DatastringBlobTransferFunction. Can only be modified if the MPTIssuance has thelsmfDataMutableflag set. Setting an emptyDataremoves the field.7.2. Transaction Fee
An$base_fee * 10$ ) + 5 drops per byte in the
MPTokenIssuanceSettransaction with aTransferFunctioncosts an additional 100 drops (TransferFunction.7.3. Failure Conditions
The existing failure conditions are still included, plus:
TransferFunctionis not valid WASM code or is invalid in some other way (e.g., using a nonexistent host function).TransferFunctiondoes not abide by the ABI (must have atransfer()function that takes no parameters and returns i32).TransferFunctionexceeds the size limit (100 KB, as specified in FeeSettings).Dataexceeds the size limit (4 KB, as specified in FeeSettings).TransferFunctionis being modified but the MPTIssuance does not have theTransferFunctionMutableflag set.Datais being modified but the MPTIssuance does not have theDataMutableflag set.tmfMPTClearCanTradeis set butDatais not cleared.7.4. State Changes
If the transaction is successful:
MPTokenIssuanceobject is updated with the newTransferFunctionand/orDatafields, if applicable.8. Transaction:
Payment8.1. Fields
As a reference, here are the existing fields for the
Paymenttransaction.AmountDeliverMax.CredentialIDsDeliverMaxDeliverMinDestinationDestinationTagDomainIDInvoiceIDPathsSendMaxThe existing fields still exist. This field is proposed as an addition:
ComputationAllowancenumberUInt32TransferFunction. Required if the MPTIssuance has aTransferFunctionfield.8.2. Failure Conditions
The existing failure conditions are still included, plus:
ComputationAllowanceis included, but theMPTIssuancedoesn't have aTransferFunctionMPTIssuancehas aTransferFunction, but aComputationAllowanceisn't includedComputationAllowanceprovided is not enough gas to complete the execution of theTransferFunctionTransferFunctionreturns 0 or a negative number (transfer is disallowed)8.3. Metadata Changes
There are two additional metadata fields:
GasUsedTransferFunction. Only present if the MPTIssuance has aTransferFunctionfield.WasmReturnCodeTransferFunction. Only present if the MPTIssuance has aTransferFunctionfield.9. Transaction:
EscrowFinishSimilar changes will apply to
EscrowFinish,ConfidentialSend,PaymentChannelClaim,CheckCash9.1. Fields
As a reference, here are the existing fields for the
MPTokenIssuancetransaction.IssuerAssetScale0, meaning that the MPT cannot be divided into smaller than 1 unit.MaximumAmountOutstandingAmountLockedAmountOutstandingAmount.TransferFeeTransferFeeof 50,000 corresponds to 50%. The default value for this field is 0. Any decimals in the transfer fee are rounded down. The fee can be rounded down to zero if the payment is small. Issuers should make sure that their MPT'sAssetScaleis large enough.MPTokenMetadataOwnerNodePreviousTxnIDPreviousTxnLgrSeqSequenceSequence(orTicket) number of the transaction that created this issuance. This helps to uniquely identify the issuance and distinguish it from any other later MPT issuances created by this account.The existing fields still exist as-is. This field is proposed as an addition:
ComputationAllowancenumberUInt32TransferFunction. Required if the MPTIssuance has aTransferFunctionfield.9.2. Failure Conditions
The existing failure conditions are still included, plus:
ComputationAllowanceis included, but theMPTIssuancedoesn't have aTransferFunctionMPTIssuancehas aTransferFunction, but aComputationAllowanceisn't includedComputationAllowanceprovided is not enough gas to complete the execution of theTransferFunctionTransferFunctionreturns 0 or a negative number (transfer is disallowed)9.3. Metadata Changes
There are two additional metadata fields:
GasUsedTransferFunction. Only present if the MPTIssuance has aTransferFunctionfield.WasmReturnCodeTransferFunction. Only present if the MPTIssuance has aTransferFunctionfield.10. Transaction:
PaymentChannelClaimAs a reference, here are the existing fields for the
PaymentChannelClaimtransaction.AmountSignature. This must match the amount in the signed message. This is the cumulative amount of XRP that can be dispensed by the channel, including XRP previously redeemed. Must be provided except when closing the channel.BalanceAmountof the signed claim. Must be provided except when closing the channel.ChannelCredentialIDsPublicKeyPublicKeystored in the ledger for the channel. Required unless the sender of the transaction is the source address of the channel and theSignaturefield is omitted. (The transaction includes the public key so thatrippledcan check the validity of the signature before trying to apply the transaction to the ledger.)Signature10.1. Fields
The existing fields still exist as-is. This field is proposed as an addition:
ComputationAllowancenumberUInt32TransferFunction. Required if the MPTIssuance has aTransferFunctionfield.10.2. Failure Conditions
The existing failure conditions are still included, plus:
ComputationAllowanceis included, but theMPTIssuancedoesn't have aTransferFunctionMPTIssuancehas aTransferFunction, but aComputationAllowanceisn't includedComputationAllowanceprovided is not enough gas to complete the execution of theTransferFunctionTransferFunctionreturns 0 or a negative number (transfer is disallowed)10.3. Metadata Changes
There are two additional metadata fields:
GasUsedTransferFunction. Only present if the MPTIssuance has aTransferFunctionfield.WasmReturnCodeTransferFunction. Only present if the MPTIssuance has aTransferFunctionfield.11. Transaction:
CheckCash11.1. Fields
As a reference, here are the existing fields for the
CheckCashtransaction.CheckIDAmountSendMaxof the corresponding CheckCreate transaction. You must provide either this field orDeliverMin.DeliverMinSendMaxof the corresponding CheckCreate transaction. You must provide either this field orAmount.The existing fields still exist as-is. This field is proposed as an addition:
ComputationAllowancenumberUInt32TransferFunction. Required if the MPTIssuance has aTransferFunctionfield.11.2. Failure Conditions
The existing failure conditions are still included, plus:
ComputationAllowanceis included, but theMPTIssuancedoesn't have aTransferFunctionMPTIssuancehas aTransferFunction, but aComputationAllowanceisn't includedComputationAllowanceprovided is not enough gas to complete the execution of theTransferFunctionTransferFunctionreturns 0 or a negative number (transfer is disallowed)11.3. Metadata Changes
There are two additional metadata fields:
GasUsedTransferFunction. Only present if the MPTIssuance has aTransferFunctionfield.WasmReturnCodeTransferFunction. Only present if the MPTIssuance has aTransferFunctionfield.12. Transaction:
ConfidentialSendConfidentialSendis a transaction included in the Confidential MPT amendment proposal. It allows a confidential transfer of MPT value between accounts while keeping the amount hidden.12.1. Fields
As a reference, here are the existing fields for the
ConfidentialSendtransaction.The existing fields still exist as-is. This field is proposed as an addition:
ComputationAllowancenumberUInt32TransferFunction. Required if the MPTIssuance has aTransferFunctionfield.12.2. Failure Conditions
The existing failure conditions are still included, plus:
ComputationAllowanceis included, but theMPTIssuancedoesn't have aTransferFunctionMPTIssuancehas aTransferFunction, but aComputationAllowanceisn't includedComputationAllowanceprovided is not enough gas to complete the execution of theTransferFunctionTransferFunctionreturns 0 or a negative number (transfer is disallowed)12.3. Metadata Changes
There are two additional metadata fields:
GasUsedTransferFunction. Only present if the MPTIssuance has aTransferFunctionfield.WasmReturnCodeTransferFunction. Only present if the MPTIssuance has aTransferFunctionfield.13. Host Functions
The following host functions will be added to the WASM VM, only enabled for Smart MPTs:
update_user_data(account_ptr: i32,account_len: i32,data_ptr: i32,data_len: i32)Datafield in theMPTokenobject corresponding to the provided holder.update_data(data_ptr: i32,data_len: i32)Datafield inMPTokenIssuanceobject.14. Rationale
The core motivation is to move critical compliance functions from off-chain systems directly onto the XRPL, making Multi-Purpose Tokens (MPTs) a viable standard for tokenized assets like securities.
transfer()function signature (no parameters, returnsi32) enforces a simple, auditable Allowed/Disallowed outcome, protecting the integrity of the ledger. A return value14.1. Alternate Designs Considered
14.2. Related Work
14.3. Objections and Concerns
During the proposal's discussion, two primary concerns were raised:
Datafield (4 KB), as defined in FeeSettings, to ensure the feature remains lightweight and scalable for the ledger.15. Security Considerations
The access control for managing the MPToken issuance and transfer is highly restricted to ensure security and predictable behavior. Specifically:
TransferFunction.TransferFunctionwill be able to modify theDataon theMPTokenIssuanceobject.TransferFunctionwill be able to modify theDataon theMPTokenobject.This design incorporates a key security measure by using a fully sandboxed WASM Virtual Machine (VM) (as outlined in detail in XLS-102). The WASM VM's write access is strictly limited to the two specified
Datafields (MPTokenIssuanceandMPTokenobjects), which fundamentally prevents the code from initiating unauthorized transactions or "stealing money". However, users should be aware of a potential risk: a bug or error in the developer-written WASM code could inadvertently "brick" a token, preventing it from being traded or transferred as intended.Appendix
Appendix A: FAQ
A.1: Why is this only for MPTs? Why not also support IOUs?
It's a lot easier to integrate this paradigm in MPTs vs IOUs - there's an issuance object where this data can be stored, there's a definite issuer, and there's no additional complication of rippling.
A2: Can Smart MPTs be traded on the DEX?
No.
Beta Was this translation helpful? Give feedback.
All reactions