Using Smart Sessions
How are smart sessions activated?1
Deploy Smart Account
You deploy the Nexus smart account on all the chains where you want to use the
smart sessions
2
Install Sessions Module
Nexus smart account is modular which means you can install custom modules on the
account which extend its functionality. One of those modules is the smart sessions
module.
3
Define and Grant Permissions
The developer defines all the permissions which they want the session signer
to have. The user must sign a payload which will grant those permissions to
the session signer.
4
Consume Permissions
The session signer can begin consuming permissions.
Implement
1
Setup & Boilerplate
2
Preparing the Account
We need to deploy the orchestrator account on all chains where we plan to use it and
install the Smart Sessions module.Recommended: Use
This will:Or, you can manually check each chain - whether or not the deployment exists on that chain
If the Smart Account is already deployed and the Smart Session module is installed on every required chain, this step can be skipped.
Recommended: Use prepareForPermissions
This will:- Deploy the account where needed
- Install the Smart Session module
- Use a funding token (e.g. USDC) to pay fees
- Optionally send trigger transactions (e.g. transfer USDC to Nexus)
3
Granting Permissions
Once setup is complete, grant limited access to the
sessionSigner
:What You’re Controlling:
- What they can do: (
actionTarget
,actionTargetSelector
,actionPolicies
) - Where they can do it: (
chainId
) - How long / how often: via policy
- How much gas/fees/tokens:
maxPaymentAmount
sessionDetails
safely—this object is required to use the permission later.This example is using grantPermissionTypedDataSign
method. It will prompt user with an EIP-712 signature request (signTypedData).
If you want personal_sign
, use grantPermissionPersonalSign
method.4
Using the Permission
This is done by the session signer, on behalf of the owner. Setup is slightly different:Setting custom If you are using
Use the Permission:
verificationGasLimit
may be useful if your permission contains numerous policies.
Please note, that this custom value will only be applied to one userOp within the superTxn,
which is using the permission for the first time and enabling it.
All other userOps which only use permission and not enable it, will have have a smaller
verification gas limit.Sponsored superTxn
You can optionally sponsor the transaction:sponsorship: true
, do not provide the feeToken
param when granting the permission.Summary
- Prepare the smart account and install modules
- Grant permission from owner to session key
- Use that permission from the session key (under strict constraints)