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%
1.4 KB · 51 lines swift
Raw Blame History
1import Foundation23public enum SystemProgram: SolanaBasicProgram {4    // MARK: - Nested type56    public enum Index {7        static let create: UInt32 = 08        static let transfer: UInt32 = 29    }1011    // MARK: - Properties1213    public static var id: PublicKey {14        "11111111111111111111111111111111"15    }1617    // MARK: - Instruction builders1819    public static func createAccountInstruction(20        from fromPublicKey: PublicKey,21        toNewPubkey newPubkey: PublicKey,22        lamports: UInt64,23        space: UInt64,24        programId: PublicKey25    ) -> TransactionInstruction {26        TransactionInstruction(27            keys: [28                AccountMeta(publicKey: fromPublicKey, isSigner: true, isWritable: true),29                AccountMeta(publicKey: newPubkey, isSigner: true, isWritable: true),30            ],31            programId: SystemProgram.id,32            data: [Index.create, lamports, space, programId]33        )34    }3536    public static func transferInstruction(37        from fromPublicKey: PublicKey,38        to toPublicKey: PublicKey,39        lamports: UInt6440    ) -> TransactionInstruction {41        TransactionInstruction(42            keys: [43                AccountMeta(publicKey: fromPublicKey, isSigner: true, isWritable: true),44                AccountMeta(publicKey: toPublicKey, isSigner: false, isWritable: true),45            ],46            programId: SystemProgram.id,47            data: [Index.transfer, lamports]48        )49    }50}51