https://github.com/blockful/deadman-switch-safe
Dead man's switch module for Safe. Transfers ownership to an heir after prolonged inactivity.
https://github.com/blockful/deadman-switch-safe
dead-man-switch ethereum foundry gnosis-safe safe smart-contracts solidity
Last synced: 3 months ago
JSON representation
Dead man's switch module for Safe. Transfers ownership to an heir after prolonged inactivity.
- Host: GitHub
- URL: https://github.com/blockful/deadman-switch-safe
- Owner: blockful
- License: mit
- Created: 2026-03-01T03:30:42.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-03-01T03:32:37.000Z (4 months ago)
- Last Synced: 2026-03-01T03:34:02.448Z (4 months ago)
- Topics: dead-man-switch, ethereum, foundry, gnosis-safe, safe, smart-contracts, solidity
- Language: Solidity
- Size: 0 Bytes
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dead Man's Switch for Safe
Designate an heir for your [Safe](https://safe.global). If the Safe owners stop signing transactions for a configurable period, the heir can claim full ownership.
```
Safe owners sign transactions as usual
(proof of life / check-in)
|
v
+------------------------+
| DeadManSwitch |
| (module + guard) |
+------------------------+
| checkAfterExecution() |-----> resets inactivity timer
+------------------------+
|
| delay passes with no activity
v
+------------------------+
| heir: triggerTakeover |
+------------------------+
|
v
Safe now has 1 owner: heir
(threshold = 1, module paused)
```
## How It Works
A single contract acts as both a Safe **module** and **guard**:
- **Guard** -- `checkAfterExecution` resets the timer after every `execTransaction` call. Only direct Safe transactions reset the timer -- calls from other modules (`execTransactionFromModule`) bypass the guard and do **not** count as activity.
- **Module** -- `triggerTakeover` uses `execTransactionFromModule` to remove all existing owners and make the heir the sole owner.
- **Manual check-in** -- Safe owners can call `ping()` via a Safe transaction to reset the timer without performing any other action. Useful if other modules are enabled whose activity won't be detected by the guard.
Deployed as **ERC-1167 minimal proxies** via `DeadManSwitchFactory` for cheap, deterministic per-Safe clones.
## Setup
After deploying a clone through the factory, execute **2 Safe transactions**:
```
safe.enableModule(deadManSwitch)
safe.setGuard(deadManSwitch)
```
## Build & Test
```bash
forge build
forge test -vvv
forge test -vvv --fork-url $RPC_URL # fork tests against mainnet Safe
```
## Deployment
```bash
# 1. Deploy factory (once per network)
forge script script/DeployFactory.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
# 2. Create clone for your Safe
FACTORY_ADDRESS=0x... SAFE_ADDRESS=0x... HEIR_ADDRESS=0x... DELAY_SECONDS=2592000 \
forge script script/DeployDeadManSwitch.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
```
## License
MIT