"In the neon-lit streets of cyberspace, your digital fortune needs a guardian that never sleeps. Welcome to the future of trustless inheritance."
Cyber-Vault is a robust dead man's switch implementation on Solana that allows users to lock SPL tokens for a specified inactivity period, after which designated beneficiaries can automatically claim the tokens. Built with pure Rust and the Anchor framework for secure and efficient smart contract development.
In a world where digital assets represent true wealth, the risk of losing access to your crypto fortune is real. Traditional inheritance systems are slow, expensive, and require trust in intermediaries. Cyber-Vault eliminates these problems through the power of immutable smart contracts.
- ๐๏ธ Vault Creation: Lock SPL tokens with a custom inactivity timer
- ๐ Heartbeat System: Extend the timer by sending periodic transactions
- ๐ฏ Automatic Claims: Token transfer to beneficiary after expiration
- ๐จ Emergency Withdraw: Owner access to partial funds while maintaining security
- ๐ฐ Rent Optimization: Automatic rent reclamation on vault closure
- ๐ก๏ธ Immutable Logic: Code is Law - mathematically guaranteed inheritance
- โก Instant Execution: No lawyers, no paperwork, no delays
graph TD
A[Owner Initializes Vault] --> B[Sets Beneficiary & Timeout]
B --> C[Deposits SPL Tokens]
C --> D[Regular Heartbeat Signals]
D --> E{Digital Silence?}
E -->|No| D
E -->|Yes - Timeout Reached| F[Automatic Transfer to Beneficiary]
D --> G[Emergency Withdrawal Available]
G --> D
- Initialize: Create your cyber-vault with a chosen beneficiary and timeout period
- Deposit: Secure your SPL tokens in the blockchain-protected vault
- Heartbeat: Send regular "proof of life" signals to reset the timer
- Inherit: If silence exceeds the timeout, assets automatically transfer to your beneficiary
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Owner Wallet โ โ Cyber-Vault โ โ Beneficiary โ
โ โโโโโถโ Smart Contractโโโโโถโ Wallet โ
โ โข Create Vault โ โ โ โ โข Claim Tokens โ
โ โข Send Heartbeatโ โ โข Lock Tokens โ โ โข Receive Funds โ
โ โข Monitor Timer โ โ โข Track Time โ โ โ
โโโโโโโโโโโโโโโโโโโ โ โข Enforce Rules โ โโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโ
// Initialize a new Cyber-Vault
pub fn create_vault(
beneficiary: Pubkey,
inactivity_period: i64,
) -> Result<()>
// Deposit SPL tokens into the vault
pub fn deposit_tokens(amount: u64) -> Result<()>
// Send heartbeat to reset dead man's switch
pub fn send_heartbeat() -> Result<()>
// Claim inheritance after timeout
pub fn claim_tokens() -> Result<()>
// Emergency withdrawal by owner
pub fn emergency_withdraw(amount: u64) -> Result<()>- Connect Wallet: Connect your Solana wallet to the dApp
- Create Vault: Initialize with beneficiary address and timeout
- Fund Vault: Deposit SPL tokens you want to protect
- Stay Active: Send regular heartbeats or make deposits
- Emergency Access: Withdraw anytime while you're alive
- Monitor Status: Check vault status and timeout countdown
- Wait for Timeout: Inheritance only available after silence period
- Claim Assets: Execute inheritance claim after timeout expires
- Receive Tokens: Assets automatically transfer to your wallet
- Solana CLI v1.18+
- Anchor Framework v0.31.1+
- Rust v1.70+ with stable toolchain
- LiteSVM for testing (included as dependency)
Note: The project uses rust-toolchain.toml to ensure consistent Rust version across environments.
# Clone the repository
git clone <repository-url>
cd cyber-vault-rs
# Build the smart contract
anchor build
# Run tests
cargo test --test cyber-vault-litesvm-tests -- --nocapture// Instruction data preparation
let beneficiary = Pubkey::new_unique();
let inactivity_period = 30 * 24 * 60 * 60; // 30 days in seconds
let amount = 1_000_000; // 1 token with 6 decimals
// PDA calculation
let (vault_pda, vault_bump) = Pubkey::find_program_address(
&[
b"vault",
owner.key().as_ref(),
beneficiary.as_ref(),
token_mint.as_ref(),
],
&program_id,
);// Build heartbeat instruction
let heartbeat_instruction = Instruction {
program_id,
accounts: vec![
AccountMeta::new(vault_pda, false),
AccountMeta::new_readonly(owner.pubkey(), true),
],
data: heartbeat_discriminator.to_vec(),
};// Build claim instruction
let claim_instruction = Instruction {
program_id,
accounts: vec![
AccountMeta::new(vault_pda, false),
AccountMeta::new(vault_token_pda, false),
AccountMeta::new(beneficiary_ata, false),
AccountMeta::new(beneficiary.pubkey(), true),
AccountMeta::new_readonly(spl_token::id(), false),
],
data: claim_discriminator.to_vec(),
};// Build emergency withdraw instruction
let emergency_withdraw_instruction = Instruction {
program_id,
accounts: vec![
AccountMeta::new(owner.pubkey(), true),
AccountMeta::new(vault_pda, false),
AccountMeta::new(owner_ata, false),
AccountMeta::new(vault_token_pda, false),
AccountMeta::new_readonly(spl_token::id(), false),
],
data: emergency_withdraw_data,
};cyber-vault-rs/
โโโ programs/
โ โโโ cyber-vault-rs/
โ โโโ src/
โ โ โโโ lib.rs # Main program entry point
โ โ โโโ error.rs # Custom error definitions
โ โ โโโ instructions/ # Instruction handlers
โ โ โ โโโ mod.rs
โ โ โ โโโ create_vault.rs
โ โ โ โโโ heartbeat.rs
โ โ โ โโโ claim.rs
โ โ โโโ state/ # Data structures
โ โ โโโ mod.rs
โ โ โโโ vault.rs
โ โโโ Cargo.toml
โโโ tests/
โ โโโ cyber-vault-litesvm-tests.rs # Integration tests (LiteSVM)
โโโ target/
โ โโโ deploy/ # Compiled program
โ โโโ idl/ # Generated IDL
โโโ Anchor.toml # Anchor configuration
โโโ Cargo.toml # Rust workspace
โโโ rust-toolchain.toml # Rust toolchain specification
- Smart Contract Technical Reference - Detailed technical implementation
- Security Audit & Test Coverage - Comprehensive security analysis
- Anchor IDL - Generated interface specification
- Devnet Deployment Guide - Complete deployment documentation
- Transaction Analysis - Detailed transaction analysis and metrics
- Program ID Migration - Program ID migration documentation
- Solana Explorer - Live program on devnet
- Owner-only heartbeat and emergency withdraw operations
- Time verification prevents premature claims using Solana clock
- Tokens held in program-controlled accounts
- Owner can withdraw partial funds while maintaining security
- Comprehensive testing with LiteSVM
- PDA Derivation: Secure program-derived addresses
- Token Account Management: Proper SPL token handling
- Access Controls: Role-based permission system
- Timeout Logic: Mathematically verified countdown
- Requires regular interaction to maintain heartbeat
- Beneficiary must have basic Solana knowledge to claim
- Gas fees required for all operations
- Not suitable for extremely short timeout periods
- Minimum 1-hour inactivity period for security
- Self-beneficiary protection
- Balance sufficiency checks for all operations
- Zero amount transaction rejection
# Run all tests with LiteSVM
cargo test -- --nocapture
# Run specific test suites
cargo test test_cyber_vault_full_flow -- --nocapture
cargo test emergency_withdraw -- --nocapture
# Build the program
anchor build- โ 16 comprehensive test cases covering all functionality
- โ Emergency withdraw testing with 7 focused test scenarios
- โ Integration testing for complete vault lifecycle
- โ Security validation for all access controls
- โ Error handling verification for all failure modes
๐งช All 16 tests passing successfully
โ
Emergency withdraw functionality verified
โ
Access controls properly enforced
โ
Time-based validation working correctly
โ
Financial safety measures effective
- Program ID:
5QTdo3dK7pQZuYrL9ZCUWzAywpohu3gGEJBmbxqAA1gW - Framework: Anchor v0.31.1
- Language: Pure Rust
- Network: Solana Devnet โ DEPLOYED
- Deployment Tool: Surfpool (Crypto Infrastructure as Code)
- Test Coverage: 100% instruction coverage with LiteSVM
- Security Rating: A+ (see Security Audit)
- Deployment Status: โ LIVE ON DEVNET
- Deployment Date: Current session
- Network: Devnet
- Total Transactions: 314 transactions executed during deployment
- Buffer Account:
GyTQmG8oSG6Nyh5AEVXVFH5Vp63wEyBxb6ZrAcqkAqHm - Ephemeral Authority:
G3Xp6HXqsVK4EPqm4hxvrvQHW2kbGVYDFfnEr4MD3N1K(closed after deployment)
# Start local validator
solana-test-validator
# Deploy to local
anchor deploy --provider.cluster localnet# Set devnet configuration
solana config set --url devnet
# Deploy using Surfpool (recommended)
surfpool start
surfpool run deployment --env devnet
# Traditional Anchor deployment
anchor deploy --provider.cluster devnet# Set mainnet configuration
solana config set --url mainnet
# Deploy to mainnet
anchor deploy --provider.cluster mainnet# Check program account on devnet
solana program show 5QTdo3dK7pQZuYrL9ZCUWzAywpohu3gGEJBmbxqAA1gW --url devnet
# View program on Solana Explorer
# https://explorer.solana.com/address/5QTdo3dK7pQZuYrL9ZCUWzAywpohu3gGEJBmbxqAA1gW?cluster=devnet- Multi-Beneficiary Support: Split inheritance among multiple parties
- Conditional Logic: Complex inheritance rules and conditions
- Cross-Chain Integration: Support for other blockchain networks
- Mobile App: Native mobile interface for easier heartbeat management
- Notification System: Email/SMS alerts for timeout warnings
- Vault Cancellation: Owner can cancel vaults under certain conditions
- Social Recovery: Emergency recovery mechanisms
- Governance Features: Community-driven protocol upgrades
- Multi-signature Support: Enhanced security for high-value vaults
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Ensure all tests pass (
cargo test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Rust best practices
- Add comprehensive tests for new features
- Update documentation for API changes
- Use meaningful commit messages
- Ensure code passes all linting checks
ISC License - see LICENSE file for details.
IMPORTANT: This is a Proof of Concept (PoC) for educational and demonstration purposes. Do not use with real funds on mainnet without thorough testing and security audits. The developers are not responsible for any loss of funds.
This is MVP software intended for testing and development purposes only.
- Do not use with mainnet tokens until thoroughly audited
- Smart contracts are experimental and may contain bugs
- Always test with small amounts first
- Consider professional security audits for production use
- Documentation: Technical Reference
- Security Audit: Security Analysis
- Devnet Deployment: Deployment Guide
- Transaction Analysis: Transaction Metrics
- Program ID Migration: Migration Guide
- Live Program: Solana Explorer
- Issues: GitHub Issues
- Surfpool: Deployment Infrastructure
# Development
anchor build # Build Solana program
cargo test # Run tests with LiteSVM
solana-test-validator # Start local validator
# Production (Devnet)
surfpool start # Initialize deployment infrastructure
surfpool run deployment --env devnet # Deploy to devnet
solana program show 5QTdo3dK7pQZuYrL9ZCUWzAywpohu3gGEJBmbxqAA1gW --url devnet # Show program info
solana account # Check account balance
# Production (Traditional)
anchor deploy # Deploy to network
solana program show # Show program info๐ "Code is Law. Math is Truth. Your Legacy is Eternal." ๐
Built with ๐ฅ using Rust and Anchor Framework on Solana
Ready to secure your digital legacy? Welcome to the future of trustless inheritance! ๐