import { PublicKey, TransactionInstruction } from "@solana/web3.js"; import { PROGRAM, CONNECTION, transaction, WALLET } from "./helper.js"; let bookkeeper = PublicKey.findProgramAddressSync( [Buffer.from("bookkeeper")], PROGRAM ); let request = PublicKey.findProgramAddressSync( [Buffer.from("request"), WALLET.publicKey.toBuffer()], PROGRAM ); const keys = [ { pubkey: WALLET.publicKey, isSigner: true, isWritable: true, }, { pubkey: request[0], isSigner: false, isWritable: true, }, ]; let name = "hhjdshf"; let nameBuffer = Buffer.from(name); let zeroesBuffer = Buffer.from( Array.from({ length: 128 - nameBuffer.length }, () => 0) ); let input = Buffer.concat([nameBuffer, zeroesBuffer]); const data = Buffer.concat([ //enum for request : 3 for sending requests Buffer.from(Int8Array.from([3]).buffer), //enum for request type : 3 for closing file Buffer.from(Int8Array.from([3]).buffer), //name as buffer input, //file id Buffer.from(Int8Array.from([69]).buffer), ]); const tx = new TransactionInstruction({ keys: keys, programId: PROGRAM, data: data, }); const sign = await transaction(tx, CONNECTION, WALLET); console.log("transaction signature is", sign);