This example showcases how to use session keys with the Abstract Global Wallet - temporary keys that are approved to execute a pre-defined set of actions without the need for the owner to sign each transaction.
-
Get a copy of the
session-keysexample directory from the Abstract Examples repository:mkdir -p session-keys && curl -L https://codeload.github.com/Abstract-Foundation/examples/tar.gz/main | tar -xz --strip=2 -C session-keys examples-main/session-keys && cd session-keys
-
Install dependencies
pnpm install
-
Run the development server
pnpm dev
Visit http://localhost:3000 to see the app.
The example demonstrates three main components:
-
Wallet Connection: Users can connect their wallet using the Abstract Global Wallet SDK.
-
Session Creation: Once connected, users can create a session key with specific permissions:
- Time-limited access (24 hour expiry)
- Limited to specific contract interactions (NFT minting)
- Maximum fee limits for transactions
- Gas fees sponsored by a paymaster
-
NFT Minting: Using the created session key, users can mint NFTs without requiring additional wallet signatures.
The main components used in this example are:
ConnectWallet.tsx: Handles wallet connection and displays connection statusCreateSession.tsx: Creates a new session key with specific permissionsMintNft.tsx: Demonstrates using the session key to mint NFTs