Overview
Base Account uses Smart Wallet contracts under the hood. Smart contract wallets introduce a few differences in how messages are signed compared to traditional Externally Owned Accounts (EOAs). This guide explains how to properly implement message signing using Base Account, covering both standard messages and typed data signatures, as well as some edge cases.Introduction
Before walking through the details of how to sign and verify messages using Base Account, it’s important to understand some of the use cases of signing messages with wallets, as well as the key differences between EOAs and smart contracts when it comes to signing messages.Use Cases for Wallet Signatures
Blockchain-based apps use wallet signatures for two main categories:- Signatures for offchain verification: Used for authenticating users in onchain apps (e.g., Sign-In with Ethereum) to avoid spoofing. The signature is not used for any onchain action.
- Signatures for onchain verification: Used for signing onchain permissions (e.g., Permit2) or batching transactions. The signature is usually stored for future transactions.
Smart Contract Wallet Differences
Smart contract wallets handle signatures differently from EOAs in several ways:- The contract itself doesn’t produce signatures - instead, the owner (e.g., passkey) signs messages
- Verification happens through the
isValidSignature
function defined in EIP-1271 - Smart contract wallet addresses are often deterministic, allowing signature support before deployment via ERC-6492
High-level flow
In this guide, we’ll walk through the high-level flow of signing and verifying messages using Base Account.Implementation
For the purposes of this guide, we’ll use a simple example of a typed data payload that contains a permission to spend user’s funds (see Spend Permissions)Code Snippets
Example Express Server
server/typed-data.ts