const handleCreateSession = async () => {
const targetProgramPublicKey = new PublicKey(
"your_target_program_public_key"
);
const topUp = true;
const expiryInMinutes = 60;
const session = await sessionWallet.createSession(
targetProgramPublicKey,
topUp,
expiryInMinutes
);
// 你也可以指定想要充值到 session wallet 的具体金额
// 这会按指定金额充值,并在撤销时返还给 authority
const session = await sessionWallet.createSession(
targetProgramPublicKey,
topUp ? 10000000 : 0, // 0.01 SOL
expiryInMinutes
);
if (session) {
console.log("Session created:", session);
} else {
console.error("Failed to create session");
}
};