1

Some Wallet apps allow Notes (sometimes also called 'memos') attached to transactions. This other question also mentions notes can be made with the CLI:

Here's a transaction with a note I made earlier:

enter image description here

I can see transaction ID PdX96DWpeMRqjxP7tQHU7aVMkjongnQz7mmkLPmvtezvWoJzqnVfJpYu3xxmRWSTngKDQ9A7a4UP4s4Tj463jr4 has an additional instruction to the note... program (noteD9tEFTDH1Jn9B1HbpoC7Zu8L9QXRo7FjZj3PT93) specifically, which when decoded from Hex to UTF-8

const note = hexToUtf8(`54657374206e6f746520746f20726563697069656e742066726f6d204d696b65`);
expect(note).toEqual("Test note to recipient from Mike");

How do I add a note to my Solana transactions using web3.js? Is there documentation for the note program somewhere?

0

2 Answers 2

2

Answering my question to help others - there are to be two common ways to add comments to transactions:

The memo program

The memo app is a popular SPL app at the address MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr on mainnet.

npm i @solana/spl-memo

Then:

import { createMemoInstruction } from '@solana/spl-memo';

(...make whatever transaction you need)

transaction.add(
  createMemoInstruction('Hello, memo-transfer!', [payer.publicKey]),
);

await sendAndConfirmTransaction(connection, transaction, [fromKeypair]);

The note program

A note program at noteD9tEFTDH1Jn9B1HbpoC7Zu8L9QXRo7FjZj3PT93 is used by Glow Wallet. Glow made this, but I can't find documentation on it.

0

You can add memos on Token22 transfers, and the Mint can be configured to require them on any transfer: https://spl.solana.com/token-2022/extensions#required-memo-on-transfer.

If you don't want to add another dependency to your program, you can piggy-back on this functionality if your program already requires spl transfers (since most do). You can use a dummy spl transfer internally to use the memo functionality.

@mikemaccana 's Existing answer regarding the memo program (https://spl.solana.com/memo) is also correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.