Learn how to interact with your dApp using the useSessionKeyManager and SessionWalletProvider through various practical examples
createSession
method from the sessionWallet
. This method accepts three parameters:
targetProgramPublicKey
: A PublicKey
instance representing the target program you want to interact with.topUp
: A boolean value, set to true
if you want to top up an session keypair with 0.01 SOL
initially 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.
signAndSendTransaction
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.
revokeSession
method from the sessionWallet
. This method performs two actions: