Skip to content

feat(svm): implement extra.memo support for exact scheme#1688

Open
tenequm wants to merge 3 commits intocoinbase:mainfrom
cascade-protocol:feat/svm-seller-memo-impl
Open

feat(svm): implement extra.memo support for exact scheme#1688
tenequm wants to merge 3 commits intocoinbase:mainfrom
cascade-protocol:feat/svm-seller-memo-impl

Conversation

@tenequm
Copy link
Copy Markdown
Contributor

@tenequm tenequm commented Mar 18, 2026

Summary

Implements the extra.memo spec from #1682 across all three SDKs (TypeScript, Go, Python), both v1 and v2 versions.

Changes

Client (all languages, v1 + v2)

  • When extra.memo is present in payment requirements, use its UTF-8 value as the Memo instruction data
  • When absent, fall back to existing random 16-byte hex nonce (backward compatible)
  • Validate memo does not exceed MAX_MEMO_BYTES (256 bytes)

Facilitator (all languages, v1 + v2)

  • When extra.memo is present in requirements, verify:
    • Exactly one Memo instruction exists among optional instructions
    • Its data matches the expected extra.memo value (UTF-8)
  • Return specific error codes on failure: memo_count / memo_mismatch

Constants added

Language Constant Value
TypeScript MAX_MEMO_BYTES 256
Go MaxMemoBytes 256
Go ErrMemoMismatch, ErrMemoCount facilitator error constants
Go ErrMemoExceedsMaxSize client error constant
Python MAX_MEMO_BYTES 256
Python ERR_MEMO_MISMATCH, ERR_MEMO_COUNT facilitator error constants

Tests added

  • TypeScript: 4 memo-specific tests in duplicateTx.test.ts
  • Go: TestSellerMemo with 4 subtests in duplicate_tx_test.go
  • Python: TestSellerMemo class with 4 tests in test_duplicate_tx.py

All test suites pass (TS: 129, Go: 50, Python: 120). All linters/formatters clean.

Files changed (26)

TypeScript (6 files)

  • src/constants.ts - added MAX_MEMO_BYTES
  • src/exact/client/scheme.ts - v2 client memo support
  • src/exact/v1/client/scheme.ts - v1 client memo support
  • src/exact/facilitator/scheme.ts - v2 facilitator memo validation
  • src/exact/v1/facilitator/scheme.ts - v1 facilitator memo validation
  • test/unit/duplicateTx.test.ts - memo tests

Go (10 files)

  • mechanisms/svm/constants.go - added MaxMemoBytes
  • mechanisms/svm/exact/client/scheme.go + errors.go - v2 client
  • mechanisms/svm/exact/v1/client/scheme.go + errors.go - v1 client
  • mechanisms/svm/exact/facilitator/scheme.go + errors.go - v2 facilitator
  • mechanisms/svm/exact/v1/facilitator/scheme.go + errors.go - v1 facilitator
  • mechanisms/svm/exact/client/duplicate_tx_test.go - memo tests

Python (7 files)

  • mechanisms/svm/constants.py - added MAX_MEMO_BYTES, error constants
  • mechanisms/svm/__init__.py - exports
  • mechanisms/svm/exact/client.py - v2 client memo support
  • mechanisms/svm/exact/v1/client.py - v1 client memo support
  • mechanisms/svm/exact/facilitator.py - v2 facilitator memo validation
  • mechanisms/svm/exact/v1/facilitator.py - v1 facilitator memo validation
  • tests/unit/mechanisms/svm/test_duplicate_tx.py - memo tests

Changesets (3 files)

  • typescript/.changeset/svm-seller-memo.md
  • go/.changes/unreleased/svm-seller-memo.yaml
  • python/x402/changelog.d/1682.feature.md

Implement the spec change from PR coinbase#1682, adding optional seller-defined
memo support to the SVM exact scheme across all three SDKs.

Client changes (TypeScript, Go, Python - both v1 and v2):
- When extra.memo is present, use its UTF-8 value as memo instruction data
- When absent, fall back to existing random 16-byte nonce behavior
- Validate memo does not exceed MAX_MEMO_BYTES (256) limit

Facilitator changes (TypeScript, Go, Python - both v1 and v2):
- When extra.memo is present in requirements, verify exactly one memo
  instruction exists and its data matches the expected value
- Return specific error codes: memo_count / memo_mismatch

Constants added:
- MAX_MEMO_BYTES / MaxMemoBytes (256) across all languages
- ERR_MEMO_MISMATCH, ERR_MEMO_COUNT (Python/Go)
- ErrMemoExceedsMaxSize (Go client)

Tests added:
- TypeScript: 4 memo tests in duplicateTx.test.ts
- Go: TestSellerMemo with 4 subtests in duplicate_tx_test.go
- Python: TestSellerMemo class with 4 tests in test_duplicate_tx.py

Closes coinbase#1682
@cb-heimdall
Copy link
Copy Markdown

cb-heimdall commented Mar 18, 2026

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 18, 2026

@tenequm is attempting to deploy a commit to the Coinbase Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added typescript go sdk Changes to core v2 packages python labels Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go python sdk Changes to core v2 packages typescript

Development

Successfully merging this pull request may close these issues.

2 participants