UNPKG

@solana/spl-memo

Version:
39 lines 1.84 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createMemoInstruction = exports.MEMO_PROGRAM_ID = void 0; const buffer_1 = require("buffer"); const web3_js_1 = require("@solana/web3.js"); exports.MEMO_PROGRAM_ID = new web3_js_1.PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr'); /** * Creates and returns an instruction which validates a string of UTF-8 * encoded characters and verifies that any accounts provided are signers of * the transaction. The program also logs the memo, as well as any verified * signer addresses, to the transaction log, so that anyone can easily observe * memos and know they were approved by zero or more addresses by inspecting * the transaction log from a trusted provider. * * Public keys passed in via the signerPubkeys will identify Signers which * must subsequently sign the Transaction including the returned * TransactionInstruction in order for the transaction to be valid. * * @param memo The UTF-8 encoded memo string to validate * @param signerPubkeys An array of public keys which must sign the * Transaction including the returned TransactionInstruction in order * for the transaction to be valid and the memo verification to * succeed. null is allowed if there are no signers for the memo * verification. **/ function createMemoInstruction(memo, signerPubkeys) { const keys = signerPubkeys == null ? [] : signerPubkeys.map(function (key) { return { pubkey: key, isSigner: true, isWritable: false }; }); return new web3_js_1.TransactionInstruction({ keys: keys, programId: exports.MEMO_PROGRAM_ID, data: buffer_1.Buffer.from(memo, 'utf8'), }); } exports.createMemoInstruction = createMemoInstruction; //# sourceMappingURL=index.js.map