Session Keys - [experimental feature]
Amongst the many prospects created by Account Abstraction, we also have the possibility of creating sessions for dApp interactions.
Sessions can be used to send transactions from a dApp on behalf of a user without requiring their confirmation with a wallet.
The user is guaranteed that the dApp can only execute transactions that comply with the policies of the session up until the session expires. Let's go through the steps on how you could enable sessions in your dApps with Argent:
Installation
Creating a session as a dApp
First, you need to have a deployed account with a valid Signer. This is the account that will authorize the session and interact with the contracts of your dApp.
A session looks like/resembles this:
You can either get that by using the Account and Signer classes provided by starknet.js or by using an injected instance by a wallet.
Next, you need to come up with the permissions you would like for your session. You also need to generate the session keypair to which you want to grant these rights.
This example session will allow the dApp to execute an example endpoint on an example contract without asking the user to approve the transaction again. After signing the session, the dApp can execute all transactions listed in policies
whenever it wants and as many times as it wants.
Now you can sign the session with the account you have. Depending on how your account works, the user may get asked to sign a message
Using established sessions
With your signed session you can now use it with your dApp to do transactions without the user having to approve again.
You can also use the session when you don't have access to the main account (window.starknet.account
). You only need access to the signedSession
object and the sessionSigner
.
Having done these, congratulations! you just enabled sessions in your dApp!
NB: It's worth noting that session keys are still an experimental feature and not yet recommended for mainnet apps. However, if you need to use them in your dApp, do reach out to us at dapps@argent.xyz.
Last updated