This repository provides a MultiSigWallet implementation inspired by Safe Wallet. It demonstrates key features and best practices such as EIP-712 and EIP-1271 signature standards, k-of-n threshold logic, and modular architecture using Solidity.
The goal of this repository is to:
- Demonstrate how to implement a robust, modular MultiSigWallet smart contract system.
- Showcase the use of EIP-712 for structured data signing and EIP-1271 for smart contract signature validation.
- Provide a testable, extendable baseline inspired by an audited standard (Safe Wallet).
- Offer real usage examples and interactions through scripts to deploy, build, sign, and execute transactions.
-
Support for
k-of-nsignatures (threshold logic) -
Any actor can execute a valid transaction with sufficient owner signatures
-
Owners can be added or removed through signed transactions
-
Full support for:
- EIP-712 structured data signing
- EIP-1271 smart contract signature validation
-
Both
callanddelegateCalloperations
- HashManager: Manages hash approvals. Allows owners to pre-approve transaction hashes.
- OwnerManager: Handles owners and threshold using a Solidity-efficient linked list.
- SignatureChecker: Extends
HashManagerand validates signatures using EIP-1271 and ECDSA. - MultiSigWallet: Concrete implementation that exposes and integrates all core functionalities.
All contracts except MultiSigWallet are abstract and are inherited for modular logic separation.
yarn installyarn testAll scripts rely on configuration from utils/constants.ts and .env.
Set owners and threshold in constants.ts. Then deploy to Sepolia:
yarn deploy:multisig:sepoliayarn multisig:build_tx:add_owner- Updates
TransactionToSignin constants with the addOwner transaction. - You must set
SetNewOwner.newOwnerin constants before running.
yarn multisig:build_tx:transfer_funds- Updates
TransactionToSignwith a fund transfer. - Set
TransferNativeToken.toand.valuebeforehand.
Signs a transaction using the mnemonic provided via .env under SIGNER_MNEMONIC:
yarn multisig:sign_tx- Uses
TransactionToSign - Outputs a signature to be added to the
Signaturesarray in constants
To generate multiple signatures:
- Change
SIGNER_MNEMONIC - Re-run script to generate another signature
Executes the fully signed transaction:
yarn multisig:execute_tx- Uses
TransactionToSignandSignatures - Sends the transaction via
execTransaction - Prints resulting transaction hash
yarn multisig:owners- Outputs current owners of the MultiSigWallet
- EIP-712: Typed structured data hashing and signing
- EIP-1271: Standard Signature Validation Method for Contracts
- Safe Contracts
This repository is for educational and demonstration purposes. Always perform your own audits and security checks before using in production.