Source

Transaction Memos

Y Protocol implements a memo system for transaction identification, enabling payment references, exchange routing, and document linking while maintaining full backward compatibility.

4 Memo Types
64 Byte Text Support
Backward Compatible
0.0001 YPC Fee

Why Memos Matter

Exchange Integration

Exchanges can use ID memos to route deposits to the correct customer accounts without requiring unique addresses for each user.

Business Payments

Businesses can include invoice numbers, order references, or payment descriptions directly in the transaction.

Compliance Ready

Support for regulatory requirements like travel rule compliance by including necessary reference information.

Memo Types

Memo::Text
64 bytes
UTF-8 text for payment references, order numbers, and notes

Example:

"Invoice #12345"

Use Cases:

Payment references, order IDs, customer notes

Memo::ID
8 bytes (u64)
64-bit unsigned integer for customer IDs and routing

Example:

123456789

Use Cases:

Exchange customer IDs, account numbers, routing codes

Memo::Hash
32 bytes
SHA-256 hash for document references and external data

Example:

0x1234...abcd

Use Cases:

Invoice hashes, document references, external data links

Memo::None
1 byte
No memo (default for backward compatibility)

Example:

null

Use Cases:

Simple transfers, privacy-focused transactions

Implementation Examples

Creating Transactions with Memos
// Text memo for invoice reference
let memo = Memo::text("Invoice #12345").unwrap();
let tx = Transaction::new_with_memo(
    "y_sender".to_string(),
    "y_recipient".to_string(),
    "1000000000".to_string(),  // 10 YPC
    "10000".to_string(),        // 0.0001 YPC fee
    nonce,
    timestamp,
    memo,
);

// ID memo for exchange routing
let customer_id = 987654321u64;
let memo = Memo::id(customer_id);

// Hash memo for document reference
let document_hash = sha256(invoice_data);
let memo = Memo::hash(&document_hash).unwrap();

// No memo (backward compatible)
let tx = Transaction::new(...); // Defaults to Memo::None

Technical Features

Backward Compatible

Existing transactions work unchanged with Memo::None as default

Transaction Integrity

Memos are included in transaction signatures and ID calculation

Deterministic Encoding

Binary encoding with type prefixes for consistent hashing

Low-Cost Fees

Only 0.0001 YPC per transaction regardless of memo size

Real-World Use Cases

Exchange Deposit Routing
Customer deposits to a shared exchange address with unique ID memo
Customer ID: 987654321
Exchange Address: y_exchange_hot_wallet
Memo Type: ID
Result: Exchange automatically credits customer account #987654321
Business Invoice Payment
B2B payment with invoice reference for automatic reconciliation
Invoice: INV-2024-001234
Memo Type: Text
Result: Accounting system automatically matches payment to invoice
Document-Backed Transaction
Legal document hash included for audit trail and verification
Document: Service Agreement PDF
SHA-256: 0x1a2b3c4d...
Memo Type: Hash
Result: Immutable link between payment and legal document

Testing Coverage

Test Suite
26 tests covering all memo functionality and edge cases
Memo type validation and size limits
Transaction ID uniqueness with different memos
Signature verification including memo data
Backward compatibility with existing transactions
JSON serialization and deserialization
Real-world scenarios (exchange, invoice, document)
International UTF-8 character support