@@ -909,13 +909,17 @@ import {
909
909
Transaction ,
910
910
LAMPORTS_PER_SOL ,
911
911
} from ' @solana/web3.js' ;
912
+ import { createMemoInstruction } from ' @solana/spl-memo' ;
912
913
import {
914
+ createAssociatedTokenAccount ,
913
915
createMint ,
914
916
createEnableRequiredMemoTransfersInstruction ,
915
917
createInitializeAccountInstruction ,
918
+ createTransferInstruction ,
916
919
disableRequiredMemoTransfers ,
917
920
enableRequiredMemoTransfers ,
918
921
getAccountLen ,
922
+ mintTo ,
919
923
ExtensionType ,
920
924
TOKEN_2022_PROGRAM_ID ,
921
925
} from ' @solana/spl-token' ;
@@ -993,6 +997,43 @@ Signature: 5MnWtrhMK32zkbacDMwBNft48VAUpr4EoRM87hkT9AFYvPgPEU7V7ERV6gdfb3kASri4w
993
997
</TabItem >
994
998
</Tabs >
995
999
1000
+ #### Example: Transferring with a memo
1001
+
1002
+ When transferring into an account with required transfer memos, you must include
1003
+ a memo instruction before the transfer.
1004
+
1005
+ <Tabs className = " unique-tabs" groupId = " language-selection" >
1006
+ <TabItem value = " cli" label = " CLI" default >
1007
+
1008
+ ``` console
1009
+ $ spl-token transfer EbPBt3XkCb9trcV4c8fidhrvoeURbDbW87Acustzyi8N 10 4Uzz67txwYbfYpF8r5UGEMYJwhPAYQ5eFUY89KTYc2bL --with-memo " memo text"
1010
+ Signature: 5a9X8JrWzwZqb3iMonfUfSZbisQ57aEmW5cFntWGYRv2UZx8ACkMineBEQRHwLMzYHeyFDEHMXu8zqAMv5tm4u1g
1011
+ ```
1012
+
1013
+ </TabItem >
1014
+ <TabItem value = " jsx" label = " JS" >
1015
+
1016
+ ``` jsx
1017
+ const sourceTokenAccount = await createAssociatedTokenAccount (
1018
+ connection,
1019
+ payer,
1020
+ mint,
1021
+ payer .publicKey ,
1022
+ undefined ,
1023
+ TOKEN_2022_PROGRAM_ID
1024
+ );
1025
+ await mintTo (connection, payer, mint, sourceTokenAccount, mintAuthority, 100 , [], undefined , TOKEN_2022_PROGRAM_ID );
1026
+
1027
+ const transferTransaction = new Transaction ().add (
1028
+ createMemoInstruction (' Hello, memo-transfer!' , [payer .publicKey ]),
1029
+ createTransferInstruction (sourceTokenAccount, destination, payer .publicKey , 100 , [], TOKEN_2022_PROGRAM_ID )
1030
+ );
1031
+ await sendAndConfirmTransaction (connection, transferTransaction, [payer], undefined );
1032
+ ```
1033
+
1034
+ </TabItem >
1035
+ </Tabs >
1036
+
996
1037
### Reallocate
997
1038
998
1039
In the previous example, astute readers of the JavaScript code may have noticed
0 commit comments