Version: 1.0.1
Status: Draft
Author: MAP Protocol Team
Table of Contents
As the blockchain ecosystem evolves, cross-chain interoperability has become a critical requirement. However, significant technical differences exist across different blockchains:
Contract Chains (e.g., Ethereum, Solana): Support smart contracts and can transmit structured data through events
Non-Contract Chains (e.g., Bitcoin, Dogecoin): Do not support smart contracts and can only transmit limited information through transaction memo/OP_RETURN fields
These differences make it difficult to unify cross-chain protocols, increasing development complexity and user comprehension costs.
1.2 What is MStack
MStack (Memo-based Stack Protocol) is a universal cross-chain standard specification for heterogeneous chains based on memo fields. It defines a concise, compact, and extensible message format that enables:
Non-contract chains to initiate and receive cross-chain requests via memo fields
Contract chains to be compatible with the same semantics through equivalent event parameters
Different cross-chain protocols to interoperate based on a unified standard
1.3 Design Goals
Applicable to all blockchains that support memo/note fields
Minimize message size to accommodate strict limits like 80 bytes
Human-readable for easy debugging and verification
Support future addition of operation types and fields
Prevent injection, replay, and other attacks
1.4 Scope of Application
MStack is applicable to the following scenarios:
Cross-chain asset transfers (Swap)
Cross-chain message passing
Cross-chain liquidity management
Cross-chain asset migration
2. Design Principles
Considering the limitations of non-contract chains, MStack is designed with memo format as the core, with contract chains achieving compatibility through adaptation layers.
2.2 Prefix-Driven
Each operation type is identified by a unique prefix for quick identification and routing:
2.3 Field Compression
To accommodate memo size limits, the following compression strategies are employed:
Chain and token names use 1-8 character aliases
Amounts support 12e8 format
Non-essential fields can be omitted
Support for shortened address formats (if available)
2.4 Version Compatibility
Version identification capability is reserved to ensure compatibility for future upgrades:
3.1 Basic Syntax
Rules:
Fixed as M, indicating MStack protocol
Single character, immediately follows prefix, no separator
No spaces allowed between fields
Chain names start with uppercase, token names are all uppercase
3.2 Operator Definitions
Operator
Memo Prefix
Operation Type
Description
Cross-chain asset exchange
Cross-chain transfer in marker
Cross-chain message (extension)
Cross-chain query (extension)
3.3 Reserved Operators
The following operators are reserved for future use:
3.4 Special Character Restrictions
MStack protocol does not support escape mechanisms. The following special characters are not supported in field values:
Vertical bar | - Used as main field separator
Other characters that conflict with separators
If user addresses or data contain these characters, alternative encoding schemes must be used or input data must be ensured not to contain conflicting characters.
4. Operation Type Definitions
4.1 Cross-Chain Swap (Mx)
Users exchange assets from the source chain to a specified token on the target chain.
Format:
Field Descriptions:
#
Field
Required
Length
Description
Target chain receiving address
Expected minimum amount to receive
Examples:
Semantics:
Cross-chain transfer source chain assets to target chain Chain
Receive Token type assets on the target chain
Assets sent to Receiver address
If Amount is specified, actual received amount should not be less than this value
If Affiliate is specified, fees are distributed according to rules
4.2 Cross-Chain Transfer In (M>)
Marks transactions transferred in from other chains, used for target chain to identify cross-chain source.
Format:
Field Descriptions:
#
Field
Required
Description
Source chain transaction hash or order ID
Example:
Semantics:
Identifies that this transaction came from FromChain via cross-chain
OrderId is used to associate with the original transaction on the source chain
4.3 Cross-Chain Refund (M<)
When cross-chain fails, assets are returned to the original sender.
Format:
Field Descriptions:
#
Field
Required
Description
Original cross-chain source chain alias
Original cross-chain transaction order ID
Example:
Semantics:
Refund associated with OriginalOrderId failed cross-chain
Assets returned to original sender address
4.4 Add Liquidity (M+)
LP Provider adds liquidity to the cross-chain protocol.
Format:
Field Descriptions:
#
Field
Required
Description
LP token receiving address
Specified liquidity pool (defaults to general pool)
Examples:
Semantics:
Add transferred assets as liquidity
LP tokens sent to Receiver address
4.5 Remove Liquidity (M-)
LP Provider removes liquidity from the cross-chain protocol.
Format:
Field Descriptions:
#
Field
Required
Description
Target chain for withdrawn assets
LP amount to withdraw (defaults to all)
Example:
Semantics:
Burn specified amount of LP tokens
Withdraw Token assets on Chain to Receiver
4.6 Asset Migration (M~)
During TSS switching, migrate assets from old Vault to new Vault.
Format:
Field Descriptions:
#
Field
Required
Description
Epoch when migration occurs
Batch ID (used for batch migrations)
Examples:
Semantics:
Initiated by old Vault managers
Transfer assets to NewVault address
Used for asset migration during TSS key rotation
4.7 Cross-Chain Message (M!) - Extension
Used for cross-chain message passing without asset transfer.
Format:
Field Descriptions:
#
Field
Required
Description
Message payload (hex encoded)
Example:
Semantics:
Call specified contract on target chain
Pass Payload as call data
5. Chain Identifier Specification
5.1 Alias Rules
First letter uppercase, rest lowercase
Globally unique, no duplicates
5.2 Predefined Chain Aliases
5.2.1 Contract Chains
Chain Name
Chain ID
Alias
Address Format
5.2.2 Non-Contract Chains
Chain Name
Alias
Address Format
5.3 Alias Registration
New chain aliases must be registered through governance process:
6. Token Identifier Specification
6.1 Alias Rules
Letters A-Z and digits 0-9 only
Unique within the same chain
6.2 Predefined Token Aliases
6.2.1 Universal Aliases
Token Type
Alias
Description
Chain's native asset (ETH, BTC, SOL, etc.)
Wrapped version (WETH, WBTC, etc.)
6.2.2 Stablecoins
6.2.3 Major Assets
Ethereum (version on non-ETH chains)
Bitcoin (version on non-BTC chains)
6.3 Token Registration
6.4 Cross-Chain Token Mapping
The same asset maintains consistent aliases across different chains:
Different chains have different address formats. MStack specifies the following unified handling rules:
Chain Type
Format Requirement
Validation Rule
Lowercase, 0x prefix, 40 hex characters
Base58, 34 characters, starts with T
^T[A-HJ-NP-Za-km-z1-9]{33}$
^[1-9A-HJ-NP-Za-km-z]{32,44}$
^[13][a-km-zA-HJ-NP-Z1-9]{25,34}$
^D[5-9A-HJ-NP-U][1-9A-HJ-NP-Za-km-z]{32}$
Uniformly use lowercase, ignore checksum
Must preserve original case
Must preserve original case
Bech32 addresses use lowercase
7.3 Address Compression (Optional)
When memo space is tight, address compression can be used:
Note: Address compression requires off-chain registry support and is not recommended for core specification use.
8. Amount Representation Specification
Amounts are represented as integers with unified decimal = 6, supporting scientific notation.
Examples:
Stored Value
Actual Amount
8.2 Scientific Notation
To save space, scientific notation is supported:
8.3 Token Representation
Since unified decimal = 6 is used, different tokens need conversion:
Token
Native Decimal
Conversion Formula
Example
Typical Amount Representations:
Token
Amount
Stored Value
Scientific Notation
8.4 Compression Strategy for 80-Byte Limit
For chains with 80-byte limits like Bitcoin, when memo space is tight, it is recommended to limit significant figures + exponent digits <= 6 (excluding e).
Compression Rules:
SF digits + exponent digits <= 6
Compression Examples:
Amount
Stored Value
Compressed
Length
Restored Value
Precision Loss
8.5 Precision Loss Analysis
Under SF + exponent digits <= 6 compression mode, maximum precision loss is approximately 0.001%:
Token
Max Amount
Max Loss
Loss Rate
Note: Compression mode is only used when memo space is tight. For chains without length limits (e.g., EVM), full precision can be used.
8.6 Precision Handling
9. Extension Field Specification
9.1 Affiliate Field
Used to identify affiliates and fee sharing, supporting both full name mode and compressed mode.
Multiple Affiliates (Full)
Multiple Affiliates (Compressed)
9.1.2 Parsing Rules
Full Name Mode:
Compressed Mode:
9.1.3 Compressed ID Rules
Starting with digits, <, >
Single Affiliate:
Multiple Affiliates:
9.1.5 Compressed ID Registry
Compressed ID
Full Name
Description
9.2 Affiliate Registration
9.3 Custom Extensions
MStack supports passing custom data through extra field:
10. Security Considerations
10.1 Injection Attack Prevention
Risk: Maliciously constructed memos may cause parsing errors or injection attacks.
Protection Measures:
10.2 Replay Attack Prevention
Risk: The same memo may be reused.
Protection Measures:
10.3 Field Length Limits
Per target chain specification
Per chain limits (see Appendix 11.3)
Note: MStack specification itself does not set a unified memo length limit. Each chain implementation handles this according to actual limits. For constrained chains like Bitcoin (80 bytes), compression techniques such as scientific notation for amounts and omitting optional fields are recommended.
11.1 Complete Examples
11.1.1 Bitcoin → Ethereum USDT
11.1.2 Ethereum → Bitcoin
11.1.3 Add BTC Liquidity
11.2 Error Code Definitions
11.3 Memo Size Limit Reference
Note: MStack specification itself does not set a unified limit. Each chain implementation handles according to above limits. For 80-byte constrained chains, compression strategies such as scientific notation for amounts and omitting optional fields are recommended.
11.4 BNF Grammar Definition
11.5 Version History
Added Amount and Affiliate compression specification
MStack is an open standard and community contributions are welcome.