Safe{Wallet} Architecture & Engineering Reference

1. What is a Safe Account?

Safe (formerly Gnosis Safe) is the canonical smart contract account architecture on Ethereum and EVM-compatible blockchains. Unlike standard Externally Owned Accounts (EOAs) where a single private key controls asset custody and state transitions, Safe functions as a programmable multisignature smart account governed by arbitrary quorum thresholds (M-of-N).

Safe secures over $100 billion in digital assets across institutional treasuries, decentralized autonomous organizations (DAOs), and individual security-conscious users. The smart contract suite is formally verified, heavily audited, and maintained as public infrastructure within the Safe Global GitHub ecosystem.

Formal Verification & Audit History The Safe core contracts are audited by OpenZeppelin, Ackee Blockchain, and Runtime Verification. The official audit reports and formal proofs are publicly available in the safe-smart-account audits documentation.
Open Safe{Wallet} App

2. EOA vs. Smart Account (Account Abstraction)

Every Ethereum account belongs to one of two fundamental categories: Externally Owned Accounts (EOAs) or Smart Contract Accounts. Safe leverages the latter to eliminate the single point of failure inherent in ECDSA private key cryptography.

Feature / Vector Standard EOA (e.g., MetaMask, Ledger) Safe Smart Account (ERC-4337 Compatible)
Private Key Custody Single seed phrase / ECDSA key pair Arbitrary M-of-N quorum of independent signers (Owner Spec)
Key Loss Resilience Catastrophic. Loss of seed equals total asset loss High. Remaining signers execute key rotation transaction via Account Recovery
Transaction Batching None. Approval + Swap requires 2 separate txs & gas Native MultiSend.sol. Batch multiple calls into a single atomic tx
Gas Sponsorship (Paymaster) Impossible on L1 without protocol-level changes Native via Safe Relay Kit and ERC-4337 Bundlers
Extensibility & Logic Fixed protocol rules, rigid EVM execution Modular (Safe Modules, Zodiac, Allowance limits, Guards)
Contract Addresses Derived from pubkey: keccak256(pubKey)[12:] Deterministic CREATE2 address across all EVM networks

3. Multi-Sig Math & Quorum Design

Selecting the optimal quorum configuration balances liveness (ability to act swiftly) against fault tolerance (resistance to loss or compromise of keys). A Safe configuration is defined as:

Threshold (M) ≤ Total Signers (N)

Under threshold M with N total signers, the account can tolerate key losses or compromised signers within mathematical bounds:

  • Loss Fault Tolerance: N - M signers can permanently lose their keys while the Safe remains fully operable.
  • Compromise Fault Tolerance: An attacker must compromise at least M separate keys to authorize an arbitrary state change or drain funds.

Interactive: Quorum & Resilience Matrix

Adjust the total owners and signature threshold below to calculate fault tolerance, collusion threshold, and operational trade-offs for your organization:

Safe Quorum Simulator
Balanced Production
3
2
Quorum Ratio
2 of 3
66.7% Consensus
Keys Can Be Lost
1 key
Without losing access
Keys To Compromise
2 keys
Attacker requirement
Relative Gas Delta
+18.4%
Signature verification cost

4. Proxy & Singleton Mastercopy Pattern

Deploying a full smart account contract for every user would consume millions in unnecessary gas. Safe solves this by separating logic (Singleton / Mastercopy) from state (Proxy) using standard EVM DELEGATECALL opcodes via the SafeProxyFactory and EIP-1167 minimal proxy architecture.

High-Level EVM Execution Flow EIP-1167 / Minimal Proxy
┌─────────────────────────────────┐
│ User / Relayer (execTransaction)│
└────────────────┬────────────────┘
                 │ 1. Transaction Call
                 ▼
┌────────────────────────────────────────────────────────┐
│ SafeProxy Contract (0xYourSafeAddress)                 │
│ Storage: owners[], threshold, nonce, modules[]         │
│ Fallback: delegatecall(singleton, msg.data)            │
└────────────────┬───────────────────────────────────────┘
                 │ 2. DELEGATECALL (Executes in Proxy Storage context)
                 ▼
┌────────────────────────────────────────────────────────┐
│ GnosisSafe.sol (Singleton Mastercopy v1.4.1)          │
│ Immutable Logic: checkSignatures(), requireValidTx()   │
└────────────────────────────────────────────────────────┘
          

When you interact with your Safe, all reads and writes happen exclusively inside your SafeProxy storage slots. The master copy remains completely stateless and shared among all Safes across the entire ecosystem.

Interactive: Canonical Contract Deployments

Safe contracts are deployed via CREATE2 (via the Nick's Method Factory) to ensure identical addresses across all canonical EVM chains. Select a network to inspect verified contract addresses:

5. Fallback Handlers & Transaction Guards

Compatibility Fallback Handler

By default, early smart contracts could not receive ERC-721 or ERC-1155 tokens because they lacked the required onERC721Received hooks. Safe solves this via the CompatibilityFallbackHandler. It also provides native EIP-1271 contract signature verification (isValidSignature(hash, signature)).

Transaction Guards (Pre/Post Execution Security)

Transaction Guards allow developers to execute arbitrary programmatic hooks before and after any execTransaction call using the BaseGuard.sol interface:

  • Pre-Hook (checkTransaction): Can verify destination allowlists, enforce transaction velocity ceilings, or block high-risk contract interactions.
  • Post-Hook (checkAfterExecution): Can verify minimum asset balances or validate state invariants after execution.

6. Safe Modules & Zodiac Extensions

While the core Safe contract is locked down to threshold consensus, Safe Modules allow granting specific execution privileges to external contracts without requiring M-of-N signatures.

Common canonical modules maintained by the Gnosis Guild and Safe Ecosystem:

Module Type Standard Implementation Primary Use-Case
Allowance Module SafeAllowanceModule.sol Allows a delegate (e.g. treasurer EOA) to spend up to X ETH per week without triggering full multisig quorum.
Zodiac Roles Modifier Zodiac: Roles Mod Granular role-based permissions (RBAC) scoping which functions of external DeFi protocols an AI agent or bot may call.
Zodiac Delay Mod Zodiac: Delay Mod Enforces a timelock on queued transactions, giving multisig owners time to veto malicious transactions.
Social Recovery SafeRecoveryModule Allows designated trusted guardians to replace compromised owner keys after an on-chain dispute window.

Interactive: Safe Transaction Execution Lifecycle

Click through each phase of a Safe multi-signature transaction to inspect the off-chain and on-chain mechanics:

PHASE 1
1. Propose & Hash
PHASE 2
2. EIP-712 Signing
PHASE 3
3. Quorum Verification
PHASE 4
4. execTransaction

7. Safe{Core} SDK — Protocol Kit Integration

The Safe Protocol Kit is the official TypeScript library for programmatically creating, signing, and executing transactions on Safe Smart Accounts, backed by the Safe Transaction Service API and the Python safe-eth-py package.


        

8. Operational Security Checklist

Critical Safe Security Rules: 1. Never set M=1 for treasury accounts. A 1-of-N threshold has the security of a hot wallet.
2. Never use identical hardware devices on the same computer without isolated seed phrases.
3. Always verify the contract address and recipient on the hardware device screen prior to signing EIP-712 hashes.
  • Geographic & Hardware Diversity: Combine different hardware vendors (e.g. Ledger + Trezor + Keystone) to avoid vendor-specific zero-day vulnerabilities.
  • Structured Data Signing: Ensure all signers verify the full EIP-712 domain separator and transaction payload hash directly on the hardware screen before approving.
  • Gas Token Independence: Maintain a gas buffer in native ETH/MATIC/ARB on the Safe to ensure signing owners never get blocked from executing critical transactions.
  • Nonce Synchronization: If a transaction with nonce K is pending, subsequent transactions cannot execute until nonce K completes or is replaced by a 0-value transaction (documented in Safe Transaction Service Nonce Guide).

9. Frequently Asked Questions

Can a Safe smart account be hacked if one owner's seed phrase is leaked?

No, provided the threshold M > 1. If 1 key in a 2-of-3 setup is compromised, the attacker cannot execute any transaction. The remaining 2 uncompromised owners can immediately execute an ownerChange transaction to replace the leaked address with a fresh key.

Are signatures stored on the blockchain?

No. Intermediate signatures are collected off-chain via EIP-712 and cached in the Safe Transaction Service. Only the final executing transaction bundles the collected signatures into the bytes signatures parameter of execTransaction, verifying them on-chain in a single atomic gas-efficient operation.

Does Safe support ERC-4337 Account Abstraction?

Yes. Safe is natively compatible with ERC-4337 via the Safe4337Module.sol contract. This enables UserOperations, decentralized Bundlers (e.g. Alto, Stackup), and ERC-4337 Paymasters for fee sponsorship in ERC-20 tokens (see Safe ERC-4337 Documentation).