This example demonstrates how to implement EIP-1271 message signing and verification with Abstract Global Wallet inside a Next.js application.
- Connect with Abstract Global Wallet
- Sign messages with your wallet
- Verification of signatures using EIP-1271 standard
-
Get a copy of the example:
mkdir -p agw-signing-messages && curl -L https://codeload.github.com/Abstract-Foundation/examples/tar.gz/main | tar -xz --strip=2 -C agw-signing-messages examples-main/agw-signing-messages && cd agw-signing-messages
-
Install dependencies
npm install
-
Run the development server
npm run dev
Visit http://localhost:3000 to see the app.
-
Frontend (
/src/components/wallet/SignMessage.tsx):- Allows users to input a custom message
- Signs the message using the connected AGW
- Automatically verifies the signature
-
Backend (
/src/app/api/verify-message/route.ts):- Provides an API endpoint for verifying signatures
- Uses viem's
verifyMessagefunction which supports EIP-1271 - Works with both regular EOA wallets and Smart Contract wallets
This implementation leverages the EIP-1271 standard which allows smart contract wallets to verify signatures. When verifying a signature:
- For EOAs: Recovers the address from the signature and compares it
- For Smart Contract Wallets: Calls the wallet's
isValidSignaturemethod