Create separate accounts for different goals, or set up accounts for friends and family — all by granting permissioned access from your main Brewit account.

Subaccounts implementation

Brewit uses a flexible session key implementation (Smart Sessions) to allow users to create subaccounts.

Smart Sessions is authored by Biconomy and Rhinestone team. It is a flexible session management validator implementation for smart accounts, providing granular access control using policies. Read more about it here.

Here is how we create and manage subaccounts using Smart Sessions:

1

Select a policy and conditions

Select a policy and conditions to allow or disallow access to your account based on the type of permission you want to grant. Currently we support 2 types of policies:

  • Full Access - Allow access to specific tokens to perform unlimited swap or spend operations. Brewit uses Sudo Policy for this.

  • Limited Access - Allow access to specific tokens to perform limited spend operations. Brewit uses ERC20SpendingLimitPolicy for this.

These policies are applied to the subaccount session as action policies.

2

Create a subaccount session

A session is needed to validate the transactions from the subaccount for these policies to work. We allow session validation using several session validators.

  • Ownable Session Validator - This validator is used to validate the embedded wallet session of social/ email login auth providers.

  • WebAuthn Passkey validator - This is slightly modified version of the original WebAuthn passkey validator to support the ISessionValidator.

3

Enable the smart session module

Once the session validator is set, we can create a subaccount session by enabling the smart session module on the smart account and adding the session details to enable the session.

4

Track/ Edit/ Remove the subaccount

We track the session details in the subaccount by querying the particular policy. We also allow the user to edit or remove the subaccount by calling the appropriate functions on the smart session module.

Smart Sessions integration guide

Read more about the Smart Sessions integration guide by Rhinestone here.

Check out the deployement details for the smart sessions module here.