What are multi-signature contracts and how do they work?
A multisig needs M of N owners to approve each transaction. How Safe works, multisig vs MPC and smart accounts, DAO treasuries, and a minimal Solidity multisig.
On this page
A multi-signature contract, or multisig, is a wallet that needs approval from several keys before it moves anything. It has a set of owners (N) and a threshold (M): any transaction needs M of the N owners to sign before it can execute. A 2-of-3 multisig survives one lost key and stops one stolen key; a 3-of-5 survives two and stops two. On Ethereum and other EVM chains the multisig is a smart contract that holds the funds and checks the signatures itself, so the rule is enforced onchain and anyone can read who the owners are and what the threshold is.
This guide covers what M-of-N means in practice, how Safe (the multisig most teams and DAOs use) works under the hood, how a multisig differs from an MPC wallet and from other smart accounts, how DAOs use multisigs next to token voting, and how to write a minimal multisig in Solidity to see the mechanics. It ends with reading a Safe's owners, balances and executed transactions.
What M-of-N means
A normal Ethereum account (an externally owned account, or EOA) has one private key, and whoever holds it can do anything. That makes the key a single point of failure twice over: lose it and the funds are stuck, leak it and they're gone. A multisig splits that control:
- Owners (N): the addresses allowed to approve transactions. Each is usually a person's own wallet, a hardware wallet, or another contract.
- Threshold (M): how many distinct owners must approve a transaction. It must be at least 1 and at most N.
- Execution: once M approvals exist, anyone can submit them onchain and the contract carries out the call: a token transfer, a contract interaction, or a change to its own owners or threshold.
Picking M and N is a trade-off between security and liveness. A higher M means more keys must be compromised to steal funds, but also more owners must be reachable to do anything. N-of-N is the strictest and the most fragile: one lost key freezes the wallet. Common setups are 2-of-3 for a small team or a personal cold-storage wallet, and 3-of-5 or 4-of-7 for a treasury, with owners on separate hardware and, ideally, separate people and locations. A multisig whose owner keys all sit with one person or on one laptop protects nothing.
Typical uses:
- Treasuries and team funds: no single employee can move company or DAO money.
- Protocol admin keys: upgrades, parameter changes and pauses need several signers instead of one deployer key.
- Personal security: a 2-of-3 with keys on two hardware wallets and a backup keeps funds safe from one lost or phished key.
- Escrow: buyer, seller and an arbiter as owners of a 2-of-3, so any two can release or refund.
How Safe works
Safe (formerly Gnosis Safe) is the standard multisig on EVM chains. Each Safe is a small proxy contract that points to a shared, audited implementation (the singleton); deploying a Safe through Safe's proxy factory only creates the proxy and stores its owners and threshold. The contracts are open source in safe-global/safe-smart-account, and the same Safe address can be deployed on several chains, but each chain's Safe is a separate contract with its own state.
Owners and threshold. The Safe stores its owners and threshold, and only a transaction approved by the owners can add or remove an owner, swap one, or change the threshold. getOwners() and getThreshold() read them.
The Safe transaction and its hash. A Safe transaction is a set of fields: to, value, data, operation (a call or a delegatecall), gas and refund parameters, and a nonce. The Safe hashes them with EIP-712 into a safeTxHash, with a domain that includes the chain ID and the Safe's own address. Owners sign that hash. Because the hash includes the nonce, the chain and the Safe, a signature can't be replayed for a second transaction, on another chain or on another Safe. The nonce goes up by one with every executed transaction.
Collecting signatures. Signing happens offchain and costs nothing. Owners sign in the Safe app or with the Safe SDK, and Safe's transaction service stores the signatures until there are enough. Then one transaction calls execTransaction with the fields and all the signatures packed together, sorted by owner address. The Safe checks each signature, rejects duplicates and non-owners, and needs at least the threshold. Its checkNSignatures accepts four kinds of signature:
- an ordinary ECDSA signature of the EIP-712 hash, from an EOA owner;
- an
eth_signsignature, for wallets that can't sign typed data; - a contract signature checked with EIP-1271, so an owner can itself be a contract, including another Safe;
- an approved hash: the owner called
approveHashonchain beforehand, or is the one sending the execution.
Modules and guards. A module is a contract the owners enable that can make the Safe execute transactions through execTransactionFromModule without owner signatures. Modules add features such as spending allowances, recovery, scheduled payments, ERC-4337 support (Safe's Safe4337Module) or executing a DAO vote. That power is why enabling one is an owner-approved transaction and why an unaudited module is the biggest risk a Safe can take on. A guard is a contract that runs checks before and after every Safe transaction and can block ones that break a policy.
Events. Every Safe since v1.3.0 emits ExecutionSuccess or ExecutionFailure with the safeTxHash after each multisig execution, and ExecutionFromModuleSuccess or ExecutionFromModuleFailure with the module's address after each module execution. The SafeL2 variant, used on L2s, also emits SafeMultiSigTransaction with the full transaction for indexers. The GoldRush code below uses these events.
Multisig vs MPC wallets vs smart accounts
These three get compared constantly, and they solve the same problem (no single key) in different places.
| Multisig contract (e.g. Safe) | MPC wallet | Smart account (ERC-4337 and others) | |
|---|---|---|---|
| Where the rule lives | Onchain, in the contract | Offchain, in the key-sharing protocol and its provider | Onchain, in the account's validation logic |
| What the chain sees | Several owners' signatures checked by a contract | One ordinary signature from one address | Whatever the account validates: one key, passkeys, M-of-N, ... |
| Who can audit the policy | Anyone, from the chain | Only the provider and the key holders | Anyone, from the chain |
| Chains | EVM chains where the contract is deployed | Any chain whose signature scheme the protocol supports | Chains where the account contract is deployed |
| Changing signers | An onchain transaction that the owners approve | Reshare the key; the address stays the same | An onchain transaction, per the account's rules |
| Cost | More gas per transaction (several signature checks) | Same gas as a normal transfer | Extra gas for validation, plus bundler and paymaster if used |
MPC wallets (multi-party computation, or threshold signatures) split one private key into shares held by different parties or devices, which compute a signature together without ever rebuilding the key. The result is a single normal signature, so the wallet looks like any EOA onchain and works on chains with no smart contracts. The trade-off is that the M-of-N policy is invisible onchain: you trust the MPC provider's software and process for it.
Smart accounts are contract wallets whose validation logic is code. A multisig is one such policy, and a Safe is a smart account: with Safe's 4337 module it can send ERC-4337 UserOperations, with gas sponsored by a paymaster. Other smart accounts validate a single key, a passkey or a session key instead. For the SDKs that build and send UserOperations from a Safe or another smart account, see ERC-4337 account abstraction SDKs. For how contract accounts differ from EOAs in general, see Ethereum accounts explained.
Multisigs in DAO governance
A DAO (decentralized autonomous organization) is a group that holds shared funds and makes decisions through smart contracts and member votes. Most DAOs keep their treasury in a Safe. The Safe is the execution layer: it holds the funds and makes the calls. What changes from DAO to DAO is how the signers know what to execute.
In the most common setup, token holders vote offchain on Snapshot, which records signed votes weighted by token balance at a block, with no gas cost. The vote has no onchain power by itself: the Safe's signers (often elected members, a council, or the core team) then execute what passed. That is cheap and flexible, but token holders are trusting the signers to follow the vote. Modules can close that gap by letting an approved Snapshot result execute through the Safe without relying on the signers, for example UMA's oSnap.
Fully onchain governance works differently. In a Governor-style system (OpenZeppelin's Governor is the usual base), the governance token itself is the vote: voting power is token-weighted, holders can delegate it to someone else (with OpenZeppelin's ERC20Votes, tokens count only once delegated, even to yourself), a proposal passes only if it meets a quorum and a majority, and a timelock executes it after a delay that gives anyone who disagrees time to exit. No group of signers can block or change the result. Some DAOs swap plain token weighting for quadratic voting, where casting n votes costs n² tokens, so large holders gain influence more slowly. Many DAOs combine the two: a Governor and timelock own the protocol, while one or more Safes handle day-to-day spending, grants, or emergency actions such as pausing a contract.
Build a minimal multisig in Solidity
To see the mechanics, here is a minimal multisig where owners confirm onchain instead of signing offchain: one owner submits a transaction, others confirm it, and any owner executes it once confirmations reach the threshold. It is written for Solidity 0.8, which checks arithmetic for overflow itself, so it needs no SafeMath.
This is for learning. Use Safe for real funds: it is audited, battle-tested and supported by wallets, block explorers and indexers, and it collects signatures offchain so confirming costs owners no gas.
// SPDX-License-Identifier: MITpragma solidity ^0.8.24; /// A teaching M-of-N multisig with onchain confirmations. Not audited: use Safe for real funds.contract MultiSigWallet { event Deposit(address indexed sender, uint256 amount); event SubmitTransaction(address indexed owner, uint256 indexed txIndex, address indexed to, uint256 value, bytes data); event ConfirmTransaction(address indexed owner, uint256 indexed txIndex); event RevokeConfirmation(address indexed owner, uint256 indexed txIndex); event ExecuteTransaction(address indexed owner, uint256 indexed txIndex); error NotOwner(); error InvalidOwner(); error InvalidThreshold(); error TxDoesNotExist(); error AlreadyExecuted(); error AlreadyConfirmed(); error NotConfirmed(); error NotEnoughConfirmations(); error CallFailed(bytes reason); struct Transaction { address to; uint256 value; bytes data; bool executed; uint256 numConfirmations; } address[] public owners; mapping(address => bool) public isOwner; uint256 public immutable threshold; Transaction[] public transactions; mapping(uint256 => mapping(address => bool)) public isConfirmed; modifier onlyOwner() { if (!isOwner[msg.sender]) revert NotOwner(); _; } modifier pending(uint256 txIndex) { if (txIndex >= transactions.length) revert TxDoesNotExist(); if (transactions[txIndex].executed) revert AlreadyExecuted(); _; } constructor(address[] memory _owners, uint256 _threshold) { if (_threshold == 0 || _threshold > _owners.length) revert InvalidThreshold(); for (uint256 i = 0; i < _owners.length; i++) { address owner = _owners[i]; if (owner == address(0) || isOwner[owner]) revert InvalidOwner(); // no zero address, no duplicates isOwner[owner] = true; owners.push(owner); } threshold = _threshold; } receive() external payable { emit Deposit(msg.sender, msg.value); } function submitTransaction(address to, uint256 value, bytes calldata data) external onlyOwner returns (uint256 txIndex) { txIndex = transactions.length; transactions.push(Transaction({to: to, value: value, data: data, executed: false, numConfirmations: 0})); emit SubmitTransaction(msg.sender, txIndex, to, value, data); } function confirmTransaction(uint256 txIndex) external onlyOwner pending(txIndex) { if (isConfirmed[txIndex][msg.sender]) revert AlreadyConfirmed(); isConfirmed[txIndex][msg.sender] = true; transactions[txIndex].numConfirmations += 1; emit ConfirmTransaction(msg.sender, txIndex); } function revokeConfirmation(uint256 txIndex) external onlyOwner pending(txIndex) { if (!isConfirmed[txIndex][msg.sender]) revert NotConfirmed(); isConfirmed[txIndex][msg.sender] = false; transactions[txIndex].numConfirmations -= 1; emit RevokeConfirmation(msg.sender, txIndex); } function executeTransaction(uint256 txIndex) external onlyOwner pending(txIndex) { Transaction storage txn = transactions[txIndex]; if (txn.numConfirmations < threshold) revert NotEnoughConfirmations(); // Mark it executed BEFORE the external call: a re-entrant call to executeTransaction now reverts. txn.executed = true; (bool ok, bytes memory reason) = txn.to.call{value: txn.value}(txn.data); // A low-level call doesn't revert on failure. Check it, or a failed transfer is recorded as executed. if (!ok) revert CallFailed(reason); emit ExecuteTransaction(msg.sender, txIndex); } function getOwners() external view returns (address[] memory) { return owners; } function transactionCount() external view returns (uint256) { return transactions.length; }}The flow, and the event each step emits:
- Deploy with the owners and the threshold, for example three addresses and
2. Fund it by sending ETH to its address (Deposit). submitTransaction(to, value, data): an owner proposes a call.datais empty for a plain ETH transfer, or ABI-encoded calldata to call a contract, such as an ERC-20transfer. The proposal gets the nexttxIndex(SubmitTransaction).confirmTransaction(txIndex): each owner confirms once (ConfirmTransaction). The proposer must confirm too; submitting isn't confirming.revokeConfirmation(txIndex): an owner can withdraw a confirmation at any time before execution (RevokeConfirmation).executeTransaction(txIndex): once confirmations reach the threshold, any owner executes it (ExecuteTransaction). It runs at most once.
The security points are the ones this kind of contract usually gets wrong:
- Check the call's return value.
address.callreturnsfalseinstead of reverting when the target reverts. Ignoring it marks a failed transfer as executed and loses the proposal. - Reentrancy on execute. The contract calls an arbitrary address with ETH. If
executedwere set after that call, the recipient could call back intoexecuteTransactionand be paid again. Setting state first (checks, effects, interactions) closes that; a reentrancy guard is a second layer. - Replay and nonces. Here each proposal has its own index and an
executedflag in storage, so it can't run twice. Designs that collect signatures offchain, like Safe, need more: a nonce in the signed message so each signature is used once, and the chain ID and contract address in it (the EIP-712 domain) so it can't be replayed on another chain or another wallet with the same owners. - What's missing. No way to change owners or the threshold (that would itself have to go through a confirmed transaction to the contract), no expiry for stale proposals, no
delegatecall, and confirming costs every owner gas. Safe has all of that, which is the reason to use it.
To try it, compile it in Remix or Foundry, deploy it to a local chain or testnet with three test accounts as owners and a threshold of 2, then submit, confirm from two owners, and execute a small ETH transfer.
Read a Safe's owners and threshold
A Safe's configuration is public: anyone can read it with eth_call. This script reads a 3-of-5 Safe on Ethereum with raw JSON-RPC requests (no library, no API key), calling each function by its 4-byte selector (how ABIs and selectors work) and pinning all reads to one block.
// Read a Safe's owners, threshold, nonce and version over plain JSON-RPC: no libraries, no API key.const RPC_URL = process.env.RPC_URL ?? "https://ethereum-rpc.publicnode.com";const SAFE = process.argv[2] ?? "0x9fC3dc011b461664c835F2527fffb1169b3C213e"; // Function selectors: the first 4 bytes of keccak256 of each signature.const SELECTORS = { getOwners: "0xa0e67e2b", // getOwners() getThreshold: "0xe75235b8", // getThreshold() nonce: "0xaffed0e0", // nonce() VERSION: "0xffa1ad74", // VERSION()}; async function call(data, block) { const res = await fetch(RPC_URL, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_call", params: [{ to: SAFE, data }, block] }), }); const { result, error } = await res.json(); if (error) throw new Error(error.message); return result.slice(2); // hex without 0x} // Split ABI-encoded return data into 32-byte words.const words = (hex) => hex.match(/.{64}/g); const blockRes = await fetch(RPC_URL, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "eth_blockNumber", params: [] }),});const block = (await blockRes.json()).result; // pin every read to one block const owners = words(await call(SELECTORS.getOwners, block)) .slice(2) // skip the array's offset and length words .map((w) => "0x" + w.slice(24));const threshold = BigInt("0x" + (await call(SELECTORS.getThreshold, block)));const nonce = BigInt("0x" + (await call(SELECTORS.nonce, block)));const [, len, text] = words(await call(SELECTORS.VERSION, block)); // ABI-encoded stringconst version = Buffer.from(text.slice(0, Number(BigInt("0x" + len)) * 2), "hex").toString(); console.log( `block ${BigInt(block)}: Safe ${version}, ${threshold}-of-${owners.length}, ${nonce} transactions executed`);console.log(owners);Run with Node 18 or later as node read-safe.mjs [safe-address]. On 21 November 2026 it printed:
block 26465445: Safe 1.4.1, 3-of-5, 62 transactions executed[ '0x5ed8cee6b63b1c6afce3ad7c92f4fd7e1b8fad9f', '0x379be87394421b6a18b19ba47cd98cc8d26b1f7a', '0x24bbc568dc89e4e57baf23b759989f3d6113bbaa', '0x26c3f6fd4f53a03ec8e54aca0c356112ca3ddec8', '0xd779332c5a52566dada11a075a735b18daa6c1f4']The nonce counts executed multisig transactions only; module executions don't use it.
See a Safe's balances and activity with GoldRush
To monitor a treasury you want two more things: what the Safe holds and what it has executed. The GoldRush Foundational API answers both for a Safe like any other address.
- The token balance API (
balances_v2) lists every token the Safe holds on a chain, with its balance and USD quote. Credit cost: 1 per call. - Log events by contract address returns every event the Safe emitted in a block range. Filtering on the execution events gives one row per executed transaction. Credit cost: 0.01 per item, counted for every log returned, including the ones you filter out.
const API = "https://api.covalenthq.com/v1";const headers = { Authorization: `Bearer ${process.env.GOLDRUSH_API_KEY}` }; // topic0 of the events every Safe (v1.3.0 and later) emits when it executes something.const TOPICS = { "0x442e715f626346e8c54381002da614f62bee8d27386535b2521ec8540898556e": "ExecutionSuccess", "0x23428b18acfb3ea64b08dc0c1d296ea9c09702c09083ca5272e64d115b687d23": "ExecutionFailure", "0x6895c13664aa4f67288b25d7a21d7aaa34916e355fb9b6fae0a139a9085becb8": "ExecutionFromModuleSuccess", "0xacd2c8702804128fdb0db2bb49f6d127dd0181c13fd45dbfe16de0930e2bd375": "ExecutionFromModuleFailure",}; async function get(path) { const res = await fetch(`${API}${path}`, { headers }); if (!res.ok) throw new Error(`${res.status} ${await res.text()}`); return (await res.json()).data;} // What a Safe holds: every token with a non-zero balance, valued in USD where a price exists.async function getSafeBalances(chain, safe) { const data = await get(`/${chain}/address/${safe}/balances_v2/?no-spam=true`); return data.items .filter((t) => t.balance && t.balance !== "0") .map((t) => ({ token: t.contract_ticker_symbol, // Number() is fine for display; use BigInt for arithmetic. balance: Number(t.balance) / 10 ** (t.contract_decimals ?? 0), usd: t.quote, }));} // What a Safe executed in a block range: one row per multisig or module execution.async function getSafeExecutions(chain, safe, startBlock, endBlock) { const data = await get(`/${chain}/events/address/${safe}/?starting-block=${startBlock}&ending-block=${endBlock}`); return data.items .filter((log) => TOPICS[log.raw_log_topics[0]]) .map((log) => { const event = TOPICS[log.raw_log_topics[0]]; const byModule = event.startsWith("ExecutionFromModule"); return { block: log.block_height, txHash: log.tx_hash, event, // safeTxHash is topic 1 from Safe v1.4.0, the first data word in v1.3.0. Modules sign nothing. safeTxHash: byModule ? null : (log.raw_log_topics[1] ?? log.raw_log_data.slice(0, 66)), module: byModule ? "0x" + log.raw_log_topics[1].slice(26) : null, }; });} const [safe, startBlock, endBlock] = process.argv.slice(2);console.table(await getSafeBalances("eth-mainnet", safe));console.table(await getSafeExecutions("eth-mainnet", safe, startBlock, endBlock));Run it as GOLDRUSH_API_KEY=... node safe-activity.mjs <safe-address> <start-block> <end-block>.
- It matches events by
topic0, the hash of the event signature, so it works whether or not a log comes back decoded, and on both Safe versions: v1.4.x indexes thesafeTxHash, v1.3.0 puts it in the data. - A module row means something executed without owner signatures. On a treasury, unexpected module executions are the first thing to alert on.
- Events come 100 to a page by default. When
pagination.has_moreistrue, addpage-numberfor the next page, or narrow the block range. - Change
eth-mainnetto another chain name to read the same Safe address there; each chain's Safe is separate. - For the transactions themselves (who sent each execution, gas paid, every token moved), use the wallet transaction history endpoint on the Safe's address.
Frequently asked questions
What is a multisig wallet?
A wallet that needs approval from several keys to send a transaction. It has N owners and a threshold M, and any transaction needs M of the N owners to sign. On EVM chains it is a smart contract, usually a Safe, that holds the funds and checks the signatures onchain.
What does 2-of-3 multisig mean?
The wallet has three owners and any two of them must approve a transaction. Losing one key doesn't lock the funds, because the other two can still sign and can replace the lost owner, and a single stolen key can't move anything on its own.
Is Gnosis Safe the same as Safe?
Yes. Gnosis Safe was renamed Safe in 2022 when it spun out of Gnosis. Its contracts are the same family: older Safes run versions such as 1.3.0 and newer ones 1.4.1, and VERSION() on a Safe tells you which.
What is the difference between a multisig and an MPC wallet?
A multisig enforces M-of-N onchain: the contract checks several owners' signatures, and anyone can see the owners and threshold. An MPC wallet splits one private key into shares that sign together offchain, so the chain sees one normal signature from one address. MPC works on any chain and costs the same gas as a normal transfer; a multisig's rule is visible and doesn't depend on a provider.
Do DAOs use multisig wallets?
Yes, most DAOs keep their treasury in a Safe. Often token holders vote offchain on Snapshot and the Safe's signers execute the result; some DAOs add a module so the approved vote executes without depending on the signers. DAOs with fully onchain governance use a Governor contract and a timelock instead, and many keep Safes alongside for grants, operations or emergency actions.
Should I write my own multisig contract?
Not for real funds. Writing one is a good way to learn the mechanics, but a custom multisig must get signature checks, replay protection, reentrancy and owner management exactly right, and wallets, explorers and indexers won't recognise it. Safe is audited, widely used and supported across EVM chains.
Next steps
- Create a Safe in the Safe app on a testnet, then read it with
read-safe.mjsabove. - Read Safe's smart account documentation on modules, guards and signatures before enabling a module.
- Compile and test the
MultiSigWalletabove in Remix or Foundry, and try to break it: execute twice, re-enter from a contract recipient, confirm as a non-owner. - Send UserOperations from a Safe with one of the ERC-4337 account abstraction SDKs.
- Monitor a treasury's holdings with the token balance API, and check what a Safe has approved with the token approvals API.