A Solana program for digital estate management with inheritance planning, trading capabilities, and multi-signature support.
The DEFAI Estate program provides:
- Digital estate creation with dead man's switch functionality
- Beneficiary management for inheritance distribution
- Real-world asset (RWA) tracking
- AI-powered trading capabilities
- Multi-signature support for enhanced security
- Emergency recovery mechanisms
- Dead Man's Switch: Automatic inheritance trigger after inactivity
- Configurable Timers:
- Inactivity period: 24 hours to 300 years
- Grace period: 24 hours to 90 days
- Check-in System: Reset timer to prevent unwanted triggers
- Asset Tracking: SOL balances and RWA management
- Support for up to 10 beneficiaries
- Percentage-based inheritance distribution (must sum to 100%)
- Email hash storage for notifications
- Individual claim tracking for tokens and NFTs
- AI Agent Integration: Joint human-AI trading accounts
- Profit Sharing: Configurable split (50-100% for human)
- Trading Strategies: Conservative, Balanced, Aggressive
- Emergency Withdrawal: Time-delayed exit mechanism
- Stop Loss: Optional percentage-based protection
- Create multi-sig accounts with 2-10 signers
- Configurable approval threshold
- Proposal-based governance for estate actions
- 48-hour timelock for admin changes
- Track off-chain assets (real estate, vehicles, jewelry, etc.)
- Metadata storage with IPFS URIs
- Soft-delete functionality
- Per-estate RWA numbering
# Ensure you're in the security-auditor directory
cd security-auditor
# Build the program
anchor build --skip-lint
# The built program will be at:
# target/deploy/defai_estate.so- Program ID:
3WN7Eiq5pCGdoCXJW4jf8NygqPv8FzTvwXZArHtYFKYV - Localnet:
HYJe4U2DToJCjb5T8tysN4784twLUk48dUjPGD7dKYut
await program.methods.initializeGlobalCounter()await program.methods.createEstate(
inactivityPeriod, // e.g., 365 * 24 * 60 * 60 (1 year)
gracePeriod, // e.g., 30 * 24 * 60 * 60 (30 days)
ownerEmailHash // SHA256 hash of owner's email
)await program.methods.updateBeneficiaries([
{
address: beneficiary1,
emailHash: emailHash1,
sharePercentage: 50,
claimed: false,
notificationSent: false
},
{
address: beneficiary2,
emailHash: emailHash2,
sharePercentage: 50,
claimed: false,
notificationSent: false
}
])await program.methods.enableTrading(
aiAgent, // AI agent pubkey
humanShare, // 50-100 (percentage)
strategy, // Conservative/Balanced/Aggressive
stopLoss, // Optional stop loss percentage
emergencyDelayHours // 24-168 hours
)// Estate Limits
pub const MIN_INACTIVITY_PERIOD: i64 = 24 * 60 * 60; // 24 hours
pub const MAX_INACTIVITY_PERIOD: i64 = 300 * 365 * 24 * 60 * 60; // 300 years
pub const MIN_GRACE_PERIOD: i64 = 24 * 60 * 60; // 24 hours
pub const MAX_GRACE_PERIOD: i64 = 90 * 24 * 60 * 60; // 90 days
pub const MAX_BENEFICIARIES: u8 = 10;
// Fees
pub const ESTATE_FEE: u64 = 100_000_000; // 0.1 SOL
pub const RWA_FEE: u64 = 10_000_000; // 0.01 SOL
// Trading Limits
pub const MAX_PROFIT_SHARE: u8 = 50; // Max 50% for AI
pub const MIN_EMERGENCY_DELAY: u32 = 24; // 24 hours
pub const MAX_EMERGENCY_DELAY: u32 = 168; // 7 days
// Admin
pub const ADMIN_TIMELOCK_DURATION: i64 = 48 * 60 * 60; // 48 hoursawait program.methods.checkIn()await program.methods.createRwa(
"realEstate", // Type
"Beach House", // Name
"Malibu property", // Description
"$2,500,000", // Value
"ipfs://..." // Metadata URI
)await program.methods.triggerInheritance()await program.methods.claimInheritance(
beneficiaryIndex // 0-based index
)// Lock
await program.methods.emergencyLock()
// Unlock
await program.methods.emergencyUnlock(verificationCode)await program.methods.initializeMultisig(
[signer1, signer2, signer3], // Signers
2 // Threshold
)await program.methods.createProposal(
targetEstate,
{
updateBeneficiaries: {
beneficiaries: [...]
}
}
)await program.methods.approveProposal(proposalId)await program.methods.executeProposal()Security checks enforced:
- Proposal must target the same estate
- Executor must be the original proposer
- Approvals must meet or exceed multisig.threshold
- Dead Man's Switch: Automatic inheritance after inactivity
- Multi-signature Support: Enhanced security for high-value estates
- Emergency Controls: Lock/unlock mechanisms
- Time Delays: Emergency withdrawals and admin changes
- Recovery System: Admin-initiated recovery after 30+ days of claimability
- Soft Deletes: RWAs are marked inactive rather than deleted
InvalidInactivityPeriod: Period outside allowed rangeInvalidGracePeriod: Grace period outside allowed rangeEstateLocked: Estate is lockedUnauthorizedAccess: Caller not authorizedEstateClaimable: Estate already in claim stateTooManyBeneficiaries: Exceeds maximum of 10InvalidBeneficiaryShares: Shares don't sum to 100%NotYetClaimable: Waiting periods not elapsedAlreadyClaimed: Beneficiary already claimedTradingAlreadyEnabled: Trading already activeInvalidProfitShare: Share outside 50-100% range
EstateCreated: New estate initializedEstateCheckedIn: Timer resetEstateLocked: Estate locked for claimsBeneficiaryUpdated: Beneficiary list changedRWACreated: New RWA addedClaimExecuted: Beneficiary claimed shareTradingEnabled: Trading activatedProfitsDistributed: Trading profits distributedMultisigCreated: New multi-sig accountProposalExecuted: Multi-sig proposal executed