Skip to content

ItsSVK/time-capsule

Repository files navigation

Time Capsule

Time Capsule is a decentralized application (dApp) on the Solana blockchain that allows users to create digital time capsules. These capsules can hold messages, promises, or predictions, locked until a specific future date. Upon unlocking, a community voting mechanism determines the resolution of the capsule, which can trigger the release of staked funds to specific destinations.

🌟 Features

Smart Contract

Built with Rust and the Anchor Framework, the smart contract provides the core logic for the Time Capsule protocol:

  • Create Capsules: Users can initialize capsules with:
    • Metadata URI (stored off-chain, e.g., IPFS/Pinata).
    • Unlock timestamp.
    • Voting duration and quorum requirements.
    • Custom token details (Name/Symbol).
  • Staking Mechanism: Users can attach SOL stakes to capsules with programmable destinations:
    • Return to Creator.
    • Burn (send to a burn address).
    • Send to a specific 3rd party address.
  • Community Governance:
    • Open for Voting: Once the time lock expires, the capsule enters a voting period.
    • Cast Vote: Community members vote on the validity or outcome of the capsule.
    • Resolve: The capsule is finalized based on the vote outcome (Pass/Fail).
  • Claim & Management:
    • Claim: Staked funds are distributed according to the resolution logic.
    • Cancel: Creators can cancel a capsule before the lock period begins.
    • Close: Clean up accounts and reclaim rent after resolution.

Frontend

A modern, responsive web interface built with Next.js 16 and React 19:

  • Interactive UI:
    • Parallax Landing Page: Engaging entry point with framer-motion animations.
    • Creation Wizard: Step-by-step process to deploy new capsules effortlessly.
    • Dashboard: View capsule status, countdown timers, and voting progress.
  • Wallet Integration: Seamless connection with Solana wallets (Phantom, Solflare, etc.) using @solana/wallet-adapter.
  • Real-time Updates: Live countdowns and state updates for capsule lifecycles.
  • Modern Tech Stack:
    • Styling: Tailwind CSS v4, Radix UI primitives for accessible components.
    • Animations: Smooth transitions and complex animations using Framer Motion.
    • Notifications: Toast notifications via sonner.

πŸ“‚ Project Structure

.
β”œβ”€β”€ Anchor.toml              # Anchor configuration
β”œβ”€β”€ programs/                # Solana Smart Contract (Rust)
β”‚   └── time-capsule/
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ instructions/ # Program instructions (Create, Vote, Claim, etc.)
β”‚       β”‚   β”œβ”€β”€ state.rs      # Account data structures
β”‚       β”‚   └── lib.rs        # Program entry point
β”œβ”€β”€ app/                     # Frontend Application (Next.js)
β”‚   β”œβ”€β”€ app/                 # Next.js App Router pages
β”‚   β”‚   β”œβ”€β”€ create/          # Capsule creation flow
β”‚   β”‚   β”œβ”€β”€ capsules/        # Capsule details and interaction pages
β”‚   β”‚   └── components/      # Shared UI components
β”‚   β”œβ”€β”€ lib/                 # Utilities and Solana integration
β”‚   └── public/              # Static assets
└── tests/                   # Integration tests (TypeScript)

πŸš€ Getting Started

Prerequisites

  • Node.js (v18+ recommended)
  • Rust & Cargo
  • Solana CLI
  • Anchor CLI

Smart Contract Setup

  1. Install Dependencies:

    yarn install
  2. Build the Program:

    anchor build
  3. Test the Program: Start a local validator and run tests:

    anchor test

Frontend Setup

  1. Navigate to the App Directory:

    cd app
  2. Install Dependencies:

    npm install
    # or
    yarn install
  3. Run Development Server:

    npm run dev
  4. Open in Browser: Visit http://localhost:3000 to see the application.

πŸ“œ Smart Contract Interface

The program ID is defined in lib.rs: BWRB15yyv6d6sbv9sq3GZxs1ptvE49QfZhzVx4n4UycJ

Key instructions:

  • initialize_capsule
  • add_stake
  • open_for_voting
  • cast_vote
  • resolve_capsule
  • claim
  • cancel_capsule
  • close_capsule

πŸ›  Technologies

  • Blockchain: Solana, Anchor
  • Frontend: Next.js, React, TypeScript, Tailwind CSS
  • Libraries: Framer Motion, Lucide React, Solana Web3.js

About

⏳ A decentralized Time Capsule dApp on Solana. πŸ”’ Lock messages and stakes until a future date, with outcomes resolved by community voting πŸ—³οΈ. Built with Anchor βš“ (Rust) and Next.js βš›οΈ.

Resources

Stars

Watchers

Forks

Contributors