Key Concepts
Authentication
Users sign messages with their wallet to authenticate themselves
Cryptographic Proof
Signatures provide cryptographic proof of wallet ownership
Instant Verification
No blockchain confirmation time - instant verification
When to Use Message Signing vs Transactions
Feature | Message Signing | Blockchain Transaction |
---|---|---|
Cost | Free | Requires SOL for fees |
Speed | Instant | Requires confirmation (~400ms) |
Storage | Off-chain (database) | On-chain (permanent) |
Use Cases | Authentication, feedback, surveys | Payments, NFT minting, DeFi |
Verification | Cryptographic signature | Blockchain consensus |
Two Approaches to Message Signing
There are two primary approaches to implementing message signing in Blinks:1. Plain Text Signing
Simple message signing with a static string. Best for basic authentication and use-cases where you don’t need the enhanced security of the structured approach.src/app/api/actions/sign-plain/route.ts
2. Structured Message Signing (Recommended)
Uses the SIWS (Sign-In With Solana) standard with anti-replay protection and domain binding. Best for production applications requiring enhanced security.Main Endpoint
src/app/api/actions/sign-structured/route.ts
Verification Endpoint
src/app/api/actions/sign-structured/verify/route.ts
- Domain binding - Message is tied to your specific domain
- Anti-replay protection - Unique nonce prevents message reuse
- Timestamp validation -
issuedAt
helps detect stale requests - Server signature - Prevents message tampering
Security Considerations
Production Security Requirements
- Store server keypairs securely (use environment variables)
- Validate all inputs thoroughly
- Implement rate limiting to prevent spam
- Use HTTPS in production
- Consider nonce expiration for time-sensitive operations
- Log security events for monitoring
Common Use Cases
Message signing is ideal for:- Wallet Based Login/Authentication - Sign in to dApps and platforms
- Token Holder Verification - Prove ownership of specific tokens or NFTs for access
- Multi-Step Flows - Combine with action chaining
- Whitelist Registration - Sign up for airdrops, presales, or exclusive events
- DAO Governance - Off-chain voting and proposal participation
- Settings Management - Change notification preferences, update profile settings
Integration with Action Chaining
Message signing works seamlessly with action chaining for multi-step flows:For a complete working example, see our Feedback Blink guide which implements message signing with database storage and action chaining.