Build real things · ≈ 16 min

Multisig: M-of-N approval

No single key can act alone. The pattern behind every treasury that has not been drained by one compromised laptop.

A multisig replaces "the owner" with "any M of these N owners". Nothing happens until enough of them independently agree.

The flow is three steps, and each is a separate transaction:

1. propose — an owner puts an action on the record and gets an id back 2. approve — other owners sign on; each approval is counted once 3. execute — once the approval count reaches the threshold, the action runs

The reason it is three steps rather than one is that owners are different people on different machines at different times. The contract is the place they meet.

Count approvers, not approvals. The single most common multisig bug is letting one owner approve the same action repeatedly and drive the counter to the threshold alone. That is a 1-of-N wearing an M-of-N costume.

Record approval per *(action, owner)* pair and ignore a repeat, exactly as you did with allowances. And check the count at execute time, not at approve time — an owner may be removed between the two.

The real contracts/examples/multisig goes considerably further: owner add/remove/replace that must itself go through the multisig (_require_self_call), a nonce to stop replay, and execute_with_permits so owners can approve off-chain with signatures and one person submits the bundle. The core below is the part everything else is built on.

Your turn

Build a 2-of-3 multisig core. propose(action) records an action and returns its id. approve(id) counts the caller once — a second approval from the same owner must NOT raise the count. execute(id) runs only at or above the threshold, and only once.

Hints

Stuck? Ask

Answered by Animica's own free inference network. It is donated GPU capacity, so give it 20-30 seconds.