Creating a Session
To create a session, call thecreateSession method from the sessionWallet. This method accepts three parameters:
targetProgramPublicKey: APublicKeyinstance representing the target program you want to interact with.topUp: A boolean value, set totrueif you want to top up an session keypair with0.01 SOLinitially and `false` if you dont want to topUp the session Keypair.expiryInMinutes: An optional parameter, representing the session’s expiry time in minutes. The default value is 60 minutes.
createSession, a new ephemeral keypair is generated and stored on the client-side. The session token is then created and stored alongside the keypair. This enables the user to securely sign transactions using the generated keypair without revealing their actual wallet’s private key.
Signing and Sending a Transaction
To sign and send a transaction, use thesignAndSendTransaction method. This method first signs the transaction using the ephemeral key pair created during the session. Then, it sends the signed transaction to the Solana network.
signAndSendTransaction method provides an extra layer of security by ensuring that the actual wallet’s private key is not exposed. The ephemeral key pair stored on the client-side is used to sign the transaction, thus keeping the user’s main wallet secure.
Revoking a Session
To revoke a session, call therevokeSession method from the sessionWallet. This method performs three actions:
- It removes the ephemeral key pair and the session token from the client-side storage.
- It revokes the session from the contract.
- Returns the lamports to the authority and closes the session token pda

