Skip to content

​What Is Memo Transfer?

The Token Extension Program’s MemoTransfer account extension requires a memo instruction immediately before any incoming transfer to that token account. Outgoing transfers from that token account do not require a memo. The extension is configured on the destination token account, not on the mint. Once enabled, transfers without a memo fail with TokenError::NoMemo until the token account owner disables the requirement.

​Before you start

The examples on this page run against a local validator at http://localhost:8899 (WebSocket ws://localhost:8900) and fund their accounts with airdrops from it. Start one in a separate terminal with Surfpool (surfpool start) or solana-test-validator. Each code section below lists the packages or crates it needs. The TypeScript examples use top-level await, so run them as ES modules, for example with npx tsx index.ts in a project whose package.json sets "type": "module".

​How to Create a Token Account with MemoTransfer Enabled

To create a token account with MemoTransfer enabled:
  1. Create and initialize a mint.
  2. Calculate the token account size and rent needed for a token account with MemoTransfer.
  3. Create the token account and enable MemoTransfer on that account.
  4. Transfer and TransferChecked instructions to that token account must include a memo instruction immediately before the transfer instruction.
1

Create and initialize the mint

Create and initialize the mint that the token account will use.
Example
2

Calculate token account size

Calculate the token account size for the base token account plus the MemoTransfer extension. This is the size used in CreateAccount.
Example
3

Calculate rent

Calculate rent using the token account size needed for the MemoTransfer extension.
Example
4

Create and initialize the token account

Create the token account with the calculated space and lamports, then initialize it for the mint.
Example
5

Enable MemoTransfer

Enable MemoTransfer on the token account.
Example

​Source Reference

ItemDescriptionSource
MemoTransferAccount extension that stores whether incoming transfers require a memo.Source
RequiredMemoTransfersInstruction::EnableInstruction that enables memo-required transfers on a token account.Source
RequiredMemoTransfersInstruction::DisableInstruction that disables memo-required transfers on a token account.Source
process_toggle_required_memo_transfersProcessor logic that initializes or rewrites the MemoTransfer extension after verifying ownership.Source

​Kit

These examples use the generated Token-2022 instructions directly.
Terminal
Instructions

​Web3.js v3

These examples use the class-based @solana/web3.js v3 API with @solana-program instruction builders.
Terminal
Instructions

​Rust

Add these dependencies to Cargo.toml (tested with Rust 1.89, 1.98, and 1.99):
Cargo.toml
Rust

​Web3.js (legacy)

These examples use legacy @solana/web3.js with @solana/spl-token. They build the memo instruction directly: @solana/spl-memo 0.3 targets a newer Memo program address that the Token-2022 memo check does not accept.
@solana/web3.js 1.x is no longer actively maintainedIt receives critical fixes only. Use Kit for new code. To migrate existing code, follow the Kit upgrade guide, or the web3.js v3 migration guide to keep the class-based API.To run this code, install 1.x with npm install @solana/web3.js@1. A plain npm install @solana/web3.js installs v3, which this code doesn’t run on.
Terminal
Instructions