ERC-7579 Modular Smart Accounts
ERC-7579 defines a standard interface for modular smart accounts. Instead of shipping monolithic wallet logic, the account is a thin shell that delegates behavior to pluggable modules.Module Types
| Type | Purpose | Example |
|---|---|---|
| Validator | Verifies signatures on UserOps | K1Validator (ECDSA secp256k1) |
| Executor | Executes arbitrary calls on behalf of the account | Session keys, automation |
| Fallback | Handles calls that don’t match any selector | Compatibility layers |
| Hook | Pre/post execution logic | Spend limits, logging |
How b402 Uses K1Validator
Every b402 smart wallet is initialized with the K1Validator module. This module validates that UserOperation signatures come from the wallet’s owner EOA using standard ECDSA (secp256k1) signature verification, the same signing scheme as MetaMask and hardware wallets. When the EntryPoint callsvalidateUserOp() on the smart account, the account delegates to K1Validator, which:
- Extracts the signer from the UserOp signature
- Compares it against the registered owner address
- Returns a validation result to the EntryPoint
installModule().
Nexus Account Factory
The Nexus Account Factory deploys smart wallets deterministically usingCREATE2. This means the wallet address can be computed off-chain before deployment.
Deterministic Address Derivation
Every b402 wallet address is derived from three inputs:- Factory address - the Nexus Account Factory contract
- Implementation - the Nexus account bytecode
- Salt - a unique value per wallet
normalizedOwnerAddress is the checksummed owner address (via getAddress()) with the 0x prefix stripped, and reversed means the hex string is reversed character-by-character. This scheme ensures a unique, deterministic mapping from owner to wallet.
Sub-Wallets
Each owner can create additional wallets by providing a custom salt. These sub-wallets share the same owner key but have distinct addresses.| Wallet Type | Salt | Typical Use |
|---|---|---|
| Master | keccak256("b402-" + reversed(owner)) | Primary wallet, auto-computed |
| Sub-wallet | Any custom bytes32 value | Ring-fenced budgets, per-project wallets |
Bootstrap Initialization
When a wallet is deployed, it is initialized through the Bootstrap contract, which:- Installs the K1Validator module with the owner address
- Sets the wallet to a ready state
- Returns control to the factory
factoryData field of the first UserOp.
Contract Addresses
| Contract | Address | Purpose |
|---|---|---|
| EntryPoint v0.7 | 0x0000000071727De22E5E9d8BAf0edAc6f37da032 | ERC-4337 singleton, executes UserOps |
| Nexus Account Factory | 0x0000006648ED9B2B842552BE63Af870bC74af837 | Deploys smart wallets via CREATE2 |
| Nexus Bootstrap | 0x0000003eDf18913c01cBc482C978bBD3D6E8ffA3 | Initializes wallet modules on deploy |
UserOperation v0.7 Format
b402 uses the ERC-4337 v0.7 unpacked format. Every field is a separate top-level property (as opposed to the packed format where paymaster fields are concatenated).Field Reference
Key Points
senderis the smart wallet address, not the owner EOA.nonceis managed by the EntryPoint contract, not the wallet itself. It includes a key + sequence pair for parallel nonce channels.factoryandfactoryDataare only present on the first UserOp when the wallet has not been deployed yet. The EntryPoint calls the factory to deploy the wallet before executing the UserOp.signatureis initially set to a dummy value (0x) by the facilitator. The client signs theuserOpHashand replaces it before settlement.
How the Facilitator Builds a UserOp
When a client sends a payment request to/wallet/verify, the facilitator constructs the unsigned UserOp through these steps:
Step 1: Validate the Request
Step 2: Check Wallet State
The facilitator checks:- Whether the wallet is deployed (determines if
factory/factoryDataare needed) - The wallet’s current nonce from the EntryPoint
- The wallet’s token balance
Step 3: Inject Protocol Fee
The facilitator adds its fee to the transaction list. The fee is configured viaWALLET_PAYMENT_FEE (percentage) and sent to WALLET_FEE_RECIPIENT.
Step 4: Encode Batch callData
ThecallData encodes a batch execution with two operations:
- Approve - approve the token for transfer
- Transfer - send tokens to the recipient (and fee to the fee recipient)
Step 5: Sign Paymaster Data
The facilitator’s paymaster signs the UserOp to authorize gas sponsorship. The paymaster signature proves the facilitator agrees to cover gas costs.Step 6: Compute UserOp Hash
TheuserOpHash is computed following the ERC-4337 spec:
Step 7: Return to Client
The Full Payment Flow
Paymaster Flow
The paymaster enables gasless transactions by sponsoring the gas cost and recovering it from the payment token.How It Works
- The facilitator’s paymaster signer (
PAYMASTER_SIGNER_KEY) signs the UserOp during/wallet/verify - The signed paymaster data is included in the
paymasterDatafield - When the bundler submits the UserOp, the EntryPoint calls the paymaster’s
validatePaymasterUserOp() - The paymaster verifies its own signature and locks the gas deposit
- After execution, the paymaster’s
postOp()is called to settle the gas accounting - The gas cost (in native gas tokens) is effectively deducted from the payment token amount
Fee Structure
| Fee | Env Variable | Description |
|---|---|---|
| Payment fee | WALLET_PAYMENT_FEE | Percentage of the payment amount |
| Deployment fee | WALLET_DEPLOYMENT_FEE | One-time fee for wallet deployment |
| Fee recipient | WALLET_FEE_RECIPIENT | Address that receives protocol fees |
Batch Execution
One of the key advantages of smart wallets is batch execution. Multiple operations are encoded into a singlecallData and executed atomically.
Approve + Transfer Pattern
With EOA wallets, you need a separate approval transaction before the payment. Smart wallets batch both into one UserOp:- No separate approval transaction
- No gas for approval (it is part of the same UserOp)
- Atomic execution (both succeed or both revert)
Deploy-on-First-Use
Smart wallets follow a deploy-on-first-use pattern:- The wallet address is computed off-chain using the factory, bootstrap, and salt
- Tokens can be sent to this address even before the wallet contract exists
- On the first payment, the UserOp includes
factoryandfactoryDatafields - The EntryPoint deploys the wallet, then executes the payment in the same transaction
factory and factoryData fields.
Getting Your Master Wallet Address
You can compute or fetch the master wallet address for any owner:Incognito Payments via Smart Wallet
Smart wallets can also execute privacy (incognito) operations by wrapping privacy pool calls in a UserOp. The/wallet/incognito/verify endpoint accepts raw contract calls:
Further Reading
- Wallet Concepts - High-level overview of EOA vs smart wallets
- Privacy Deep Dive - Privacy pool integration details
- ERC-4337 Spec - Account Abstraction specification
- ERC-7579 Spec - Modular smart account standard
