Skip to content

Berbex/Multisig-Wallet

Repository files navigation

MultiSigWallet Implementation

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.


🌟 Purpose

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.

📊 Core Features

  • Support for k-of-n signatures (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 call and delegateCall operations


📂 Contracts

  • HashManager: Manages hash approvals. Allows owners to pre-approve transaction hashes.
  • OwnerManager: Handles owners and threshold using a Solidity-efficient linked list.
  • SignatureChecker: Extends HashManager and 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.


🚀 Setup Instructions

1. Install Dependencies

yarn install

2. Run Tests

yarn test

📱 Scripts & Usage

All scripts rely on configuration from utils/constants.ts and .env.

Deployment

Set owners and threshold in constants.ts. Then deploy to Sepolia:

yarn deploy:multisig:sepolia

Build Transaction

1. Add New Owner

yarn multisig:build_tx:add_owner
  • Updates TransactionToSign in constants with the addOwner transaction.
  • You must set SetNewOwner.newOwner in constants before running.

2. Transfer Funds

yarn multisig:build_tx:transfer_funds
  • Updates TransactionToSign with a fund transfer.
  • Set TransferNativeToken.to and .value beforehand.

Sign Transaction

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 Signatures array in constants

To generate multiple signatures:

  • Change SIGNER_MNEMONIC
  • Re-run script to generate another signature

Execute Transaction

Executes the fully signed transaction:

yarn multisig:execute_tx
  • Uses TransactionToSign and Signatures
  • Sends the transaction via execTransaction
  • Prints resulting transaction hash

View Owners

yarn multisig:owners
  • Outputs current owners of the MultiSigWallet

🎓 Learn More


🚫 Disclaimer

This repository is for educational and demonstration purposes. Always perform your own audits and security checks before using in production.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

4 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors