This is a decentralized application (dApp) that allows users to create digital wills on the blockchain using smart contracts. Users can set up inheritance plans that automatically transfer their assets to beneficiaries if they become inactive for a specified period.
- Digital Will Creation: Create wills with specified beneficiaries and inactivity periods
- Heartbeat System: Send periodic "heartbeats" to keep your will active
- Automatic Inheritance: Beneficiaries can claim inheritance if the owner becomes inactive
- MetaMask Integration: Seamless wallet connection for blockchain interactions
- Modern UI: Built with React, Next.js, and TypeScript
- Create multiple wills with different beneficiaries
- Set custom inactivity periods
- Add funds to existing wills
- Automatic ETH transfer to beneficiaries upon claim
- Comprehensive will management and querying functions
- Frontend: Next.js 15, React 19, TypeScript
- Blockchain: Ethereum (Sepolia testnet), Hardhat, Ethers.js
- Wallet: MetaMask integration
- Development: ESLint, Hardhat Ignition for deployments
- Node.js (v18 or higher)
- MetaMask browser extension
- Some test ETH on Sepolia network
- Clone the repository:
git clone <repository-url>
cd metamask-connection-abdulelahragih-2- Install dependencies:
npm install- Set up environment variables:
Create a
.envfile in the root directory:
PRIVATE_KEY=your_private_key_here
SEPOLIA_RPC_URL=your_sepolia_rpc_url_here- Deploy the smart contract:
npx hardhat ignition deploy ignition/modules/DecentralizedWill.ts --network sepolia- Start the development server:
npm run dev- Open http://localhost:3000 in your browser
- Connect Wallet: Click "Connect Wallet" to connect your MetaMask
- Create Will:
- Enter beneficiary address
- Set inactivity period (in seconds)
- Send ETH to fund the will
- Send Heartbeat: Periodically send heartbeats to keep your will active
- Claim Inheritance: Beneficiaries can claim if the owner becomes inactive
├── contracts/ # Smart contracts
│ └── DecentralizedWill.sol
├── src/
│ ├── app/ # Next.js app directory
│ ├── components/ # React components
│ └── lib/ # Utility functions
├── ignition/ # Hardhat Ignition deployments
├── test/ # Test files
└── public/ # Static assets
setWill(beneficiary, inactivityPeriod)- Create a new willheartbeat(willId)- Send heartbeat to keep will activeclaim(owner, willId)- Claim inheritance as beneficiaryaddToWill(willId)- Add more funds to existing willgetWillDetails(owner, willId)- Get will informationgetAllWills(owner)- Get all wills for an address
Run the test suite:
npx hardhat testThe contract is deployed on Sepolia testnet. Check the deployment addresses in ignition/deployments/chain-11155111/deployed_addresses.json.