Decentralized Inheritance Wallet
What it does:
A smart contract wallet that automatically transfers assets to predefined heirs when inheritance conditions are met, without relying on lawyers, banks, or centralized custodians.
Why it matters:
Traditional inheritance processes are slow, expensive, and opaque. This contract enforces transparent, rule-based inheritance using code, ensuring assets reach beneficiaries safely and fairly.
How it works:
-
The owner deposits assets into an inheritance wallet.
-
Heirs and their inheritance shares are defined on-chain.
-
Inheritance is triggered by inactivity, time-lock, or guardian approval.
-
Assets are distributed automatically according to predefined shares.
-
All actions and distributions are permanently recorded on-chain.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @title DecentralizedInheritanceWallet
* @author Nam
* @notice Trustless inheritance wallet with inactivity + guardian trigger
*/
contract DecentralizedInheritanceWallet {
// -------------------- DATA STRUCTURES --------------------
struct Heir {
uint256 share; // Percentage share
bool active;
}
mapping(address => Heir) public heirs;
address[] public heirList;
address public owner;
address[] public guardians;
uint256 public inactivityPeriod;
uint256 public lastActivity;
bool public inheritanceTriggered;
uint256 public totalShares;
mapping(address => bool) public isGuardian;
mapping(address => bool) public guardianApproved;
// -------------------- EVENTS --------------------
event Deposited(address indexed from, uint256 amount);
event ActivityRecorded(address indexed owner);
event InheritanceTriggered(address indexed by);
event GuardianApproved(address indexed guardian);
event InheritanceClaimed(address indexed heir, uint256 amount);
// -------------------- MODIFIERS --------------------
modifier onlyOwner() {
require(msg.sender == owner, "Not owner");
_;
}
modifier onlyGuardian() {
require(isGuardian[msg.sender], "Not guardian");
_;
}
modifier inheritanceActive() {
require(inheritanceTriggered, "Inheritance not active");
_;
}
// -------------------- CONSTRUCTOR --------------------
constructor(
address[] memory _guardians,
uint256 _inactivityPeriod
) {
require(_guardians.length > 0, "No guardians");
owner = msg.sender;
inactivityPeriod = _inactivityPeriod;
lastActivity = block.timestamp;
for (uint256 i = 0; i 0, "Invalid share");
if (!heirs[_heir].active) {
heirList.push(_heir);
heirs[_heir].active = true;
}
totalShares = totalShares - heirs[_heir].share + _share;
heirs[_heir].share = _share;
}
/**
* @notice Deposit ETH into inheritance wallet
*/
function deposit() external payable {
require(msg.value > 0, "Zero deposit");
emit Deposited(msg.sender, msg.value);
}
// -------------------- INHERITANCE TRIGGERS --------------------
/**
* @notice Trigger inheritance via inactivity
*/
function triggerByInactivity() external {
require(
block.timestamp >= lastActivity + inactivityPeriod,
"Owner still active"
);
inheritanceTriggered = true;
emit InheritanceTriggered(msg.sender);
}
/**
* @notice Trigger inheritance via guardian approval
*/
function triggerByGuardians() external onlyGuardian {
guardianApproved[msg.sender] = true;
uint256 approvals;
for (uint256 i = 0; i guardians.length / 2) {
inheritanceTriggered = true;
emit InheritanceTriggered(msg.sender);
}
emit GuardianApproved(msg.sender);
}
// -------------------- CLAIM LOGIC --------------------
/**
* @notice Heir claims inheritance share
*/
function claim() external inheritanceActive {
Heir memory heir = heirs[msg.sender];
require(heir.active, "Not heir");
uint256 amount =
(address(this).balance * heir.share) / totalShares;
heirs[msg.sender].active = false;
payable(msg.sender).transfer(amount);
emit InheritanceClaimed(msg.sender, amount);
}
// -------------------- VIEW FUNCTIONS --------------------
/**
* @notice Get heir info
*/
function getHeir(address _heir)
external
view
returns (
uint256 share,
bool active
)
{
Heir memory h = heirs[_heir];
return (
h.share,
h.active
);
}
/**
* @notice Get guardians
*/
function getGuardians() external view returns (address[] memory) {
return guardians;
}
}