Add memo extraction helpers to the JS client - #420
Merged
Merged
Conversation
The Memo program has been deployed under several addresses over time (v1, v3 and the current v4), so consumers that filter by a single program address silently miss memos emitted under older versions. This adds getMemosFromInstructions, which matches instructions against every historical address and returns each memo's decoded text, raw bytes, source program address and instruction index. The supported addresses are exposed as a SUPPORTED_MEMO_PROGRAM_ADDRESSES constant, with the legacy addresses available individually as LEGACY_MEMO_PROGRAM_ADDRESS_V1 and LEGACY_MEMO_PROGRAM_ADDRESS_V3. The current address remains the generated MEMO_PROGRAM_ADDRESS, which should still be used when building new memo instructions. New hand-written modules (src/constants.ts, src/memos.ts) live alongside the generated code and are re-exported from src/index.ts. Unit tests cover extraction across all program versions, ordering and index preservation, multi-byte UTF-8, and the empty-data case.
amilz
approved these changes
Sep 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds helpers to the
@solana-program/memoJS client for reading memos emitted under any version of the Memo program.The Memo program has been deployed under several addresses over time (v1, v3 and the current v4), so consumers that filter by a single program address silently miss memos emitted under older versions. This adds
getMemosFromInstructions, which matches instructions against every historical address and returns each memo's decoded text, raw bytes, source program address and instruction index.The supported addresses are exposed as a
SUPPORTED_MEMO_PROGRAM_ADDRESSESconstant, with the legacy addresses available individually asLEGACY_MEMO_PROGRAM_ADDRESS_V1andLEGACY_MEMO_PROGRAM_ADDRESS_V3. The current address remains the generatedMEMO_PROGRAM_ADDRESS, which should still be used when building new memo instructions.New hand-written modules (
src/constants.ts,src/memos.ts) live alongside the generated code and are re-exported fromsrc/index.ts. Unit tests cover extraction across all program versions, ordering and index preservation, multi-byte UTF-8, and the empty-data case.