Implement session keys
Let's go through the steps on how you could enable sessions in your dApps with Argent.
Pre-requisites
pnpm add starknetkit@2.2.7
(or newer versions)can be installed with
pnpm add starknetkit@next
required in order to get the deployment data for an account
pnpm add @argent/x-sessions@next
Connect using starknetkit
Using starknetkit modal, with all default connectors
Using starknetkit modal, with all specific connectors
ARGENT_WEBWALLET_URL
Mainnet: https://web.argent.xyz/
Testnet: please reach-out to us if you wish to use web wallet on testnet
Get deployment data for an account
When connecting with starknetkit, use the wallet
object returned by connect
.
If an account is already deployed, this will throw an exception (so it will need to be managed on client side)
Create a session
Before the user can execute transactions, a session needs to be created.
The dapp will need to create a dappKey
, both public and private will be needed.
When creating a session, 2 values needs to be stored:
sessionRequest, created using
createSessionRequest
from@argent/x-sessions
sessionSignature, that requires signing a message and created using
openSession
from@argent/x-sessions
Execute a tx using session keys
In order to execute a tx, a session account is needed.
To create this account, sessionRequest
and accountSessionSignature
created on the step before a required.
You can now use this account to submit transactions.
ARGENT_SESSION_SERVICE_BASE_URL
Mainnet: https://cloud.argent-api.com/v1
Testnet: please reach-out to us if you wish to use sessions on testnet
Last updated