SPB Git

spb/os-vault Public

Self-custody, multi-chain crypto wallet for macOS. One recovery phrase, six chain families, zero API keys — nothing leaves your Mac.

Swift 96% Shell 3.4% Makefile 0.6%
684 B · 28 lines swift
Raw Blame History
1import Foundation23public enum MemoProgramError: Error {4    case invalid5}67public enum MemoProgram: SolanaBasicProgram {8    /// The public id of the program9    public static var id: PublicKey {10        "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"11    }1213    /// Create memo instruction14    public static func createMemoInstruction(15        memo: String16    ) throws -> TransactionInstruction {17        // TODO: - Memo length assertion18        guard let data = memo.data(using: .utf8) else {19            throw MemoProgramError.invalid20        }21        return TransactionInstruction(22            keys: [],23            programId: id,24            data: data.bytes25        )26    }27}28