The first on-chain insurance protocol protecting blockchain users from transaction latency, mempool congestion, and finality delays, powered by Stacks + Bitcoin security.
HyperInsure provides non-intrusive, verifiable insurance coverage for risks associated with transaction delays. Instead of paying high "tips" on top of base fees, users can purchase affordable insurance policies that provide protection against various types of transaction delays.
- Transaction Delay Protection: Coverage for transactions stuck in mempools
- Mempool Congestion Insurance: Protection during high network activity periods
- Finality Risk Coverage: Insurance against finality delays across congested networks
- Non-Intrusive Implementation: No additional parameters or code modifications needed
- Verifiable Claims Process: Transparent, on-chain verification of delays
- Purchase Coverage: Users purchase coverage by paying STX tokens and selecting a policy
- Bitcoin Transaction Verification: Users provide Bitcoin transaction details (TX ID, broadcast height, inclusion height)
- Delay Calculation: The system calculates delay using Bitcoin burn block heights (inclusion height - broadcast height)
- Smart Contract Verification: Clarity smart contracts verify Bitcoin transaction proofs and calculate delays
- Automatic Payouts: If delay ≥ policy threshold, payouts are automatically released from the STX treasury
Note: The diagrams below show the conceptual architecture. The current implementation uses direct Bitcoin transaction verification via Clarity Bitcoin Library, without requiring an RPC Proxy.
sequenceDiagram
participant Admin
participant User
participant UI
participant Insurance Contract
Note over Admin, Insurance Contract: Policy Creation (Admin Only)
Admin->>Insurance Contract: create-policy(policy-id, name, description, premium-rate, delay-threshold, protocol-fee)
Insurance Contract->>Insurance Contract: Store policy configuration
Insurance Contract-->>Admin: Policy created
Note over User, Insurance Contract: User Purchases Policy
User->>UI: View available policies
UI->>Insurance Contract: get-policy(policy-id)
Insurance Contract-->>UI: Policy details (premium rate, delay threshold, etc.)
UI-->>User: Display policy options
User->>UI: Select policy and STX amount
UI->>Insurance Contract: purchase-policy(policy-id, stx-amount, purchase-id)
Insurance Contract->>Insurance Contract: Calculate premium and store purchase
Insurance Contract->>Insurance Contract: Transfer STX to treasury
Insurance Contract-->>UI: Purchase confirmation
UI-->>User: Coverage active with purchase ID
sequenceDiagram
participant User
participant UI
participant Bitcoin API
participant Insurance Contract
participant Clarity Bitcoin Lib
User->>UI: Enter Bitcoin TX ID
UI->>Bitcoin API: Fetch transaction data
Bitcoin API-->>UI: Transaction details (broadcast height, inclusion height, fee rate)
UI->>UI: Calculate delay (inclusion - broadcast blocks)
UI-->>User: Display delay analysis
alt Delay exceeds policy threshold
User->>UI: Submit claim with TX ID and proof
UI->>Insurance Contract: submit-claim-with-proof(purchase-id, tx-id, broadcast-height, inclusion-height, merkle-proof)
Insurance Contract->>Clarity Bitcoin Lib: Verify Bitcoin transaction
Clarity Bitcoin Lib->>Clarity Bitcoin Lib: Validate merkle proof
Clarity Bitcoin Lib-->>Insurance Contract: Transaction verified
Insurance Contract->>Insurance Contract: Calculate delay using burn block heights
Insurance Contract->>Insurance Contract: Verify delay >= policy threshold
Insurance Contract->>Insurance Contract: Calculate payout amount
Insurance Contract->>User: Transfer STX payout
Insurance Contract-->>UI: Claim approved
else Delay below threshold
UI-->>User: Not eligible for claim
end
sequenceDiagram
participant User
participant UI
participant Bitcoin API
participant Insurance Contract
participant Clarity Bitcoin Lib
participant Treasury
User->>UI: Select purchase and enter Bitcoin TX ID
UI->>Bitcoin API: Fetch transaction from mempool.space/blockstream
Bitcoin API-->>UI: Transaction data (heights, confirmations, fee)
UI->>UI: Estimate broadcast height if not provided
UI->>UI: Calculate delay (inclusion height - broadcast height)
UI-->>User: Display delay analysis and eligibility
User->>UI: Submit claim
UI->>Insurance Contract: submit-claim-with-proof(purchase-id, claim-id, tx-id, broadcast-height, inclusion-height, merkle-proof)
Insurance Contract->>Insurance Contract: Verify purchase exists and active
Insurance Contract->>Clarity Bitcoin Lib: Verify Bitcoin transaction
Clarity Bitcoin Lib->>Clarity Bitcoin Lib: Validate merkle proof and block headers
Clarity Bitcoin Lib-->>Insurance Contract: Transaction verified
Insurance Contract->>Insurance Contract: Calculate delay using burn block heights
Insurance Contract->>Insurance Contract: Verify delay >= policy threshold
alt Valid claim and delay >= threshold
Insurance Contract->>Insurance Contract: Calculate payout based on premium
Insurance Contract->>Treasury: Check STX balance
Treasury-->>Insurance Contract: Balance sufficient
Insurance Contract->>User: Transfer STX payout
Insurance Contract->>Insurance Contract: Mark purchase as claimed
Insurance Contract-->>UI: Claim approved and payout sent
else Invalid claim
Insurance Contract-->>UI: Claim rejected (delay too short, invalid proof, etc.)
end
UI-->>User: Claim result with transaction details
graph TD
A[User wants Bitcoin transaction protection] --> B[Purchase insurance policy with STX]
B --> C[Policy active - coverage purchased]
C --> D[User sends Bitcoin transaction]
D --> E{Transaction delayed?}
E -->|No delay| F[Transaction confirmed on time - no claim needed]
E -->|Delayed| G[User verifies delay on Verify page]
G --> H{Delay >= policy threshold?}
H -->|No| I[Not eligible - delay too short]
H -->|Yes| J[User submits claim with TX ID and proof]
J --> K[Contract verifies Bitcoin transaction]
K --> L[Contract calculates delay using burn blocks]
L --> M{Valid claim?}
M -->|Yes| N[Automatic STX payout from treasury]
M -->|No| O[Claim rejected - see reason]
HyperInsure is built on a streamlined contract architecture with core components:
-
HYPERINSURE_CORE_V2: Main contract managing policies, purchases, claims, and treasury functions
create-policy: Admin function to create new insurance policiespurchase-policy: User function to purchase coveragesubmit-claim-with-proof: User function to submit claims with Bitcoin transaction proofsset-admin: Admin function to change contract administrator
-
Clarity Bitcoin Library: Provides Bitcoin transaction verification on-chain
- Verifies Bitcoin transaction existence
- Validates merkle proofs
- Calculates block heights and delays
-
Insurance Treasury: Manages STX reserves for instant payouts
-
Governance Contract (optional): Controls protocol parameters and upgrades
- Next.js 15.2.4 - React framework with App Router
- React 19 - UI library
- TypeScript - Type safety
- Tailwind CSS - Utility-first CSS framework
- shadcn/ui - Accessible component library
- @stacks/connect-react - Stacks wallet integration
- @stacks/transactions - Stacks transaction building
- sonner - Toast notifications
- lucide-react - Icon library
- framer-motion - Animations
- Stacks blockchain - Layer 1 blockchain
- Clarity smart contracts - Decidable smart contract language
- Bitcoin security - Burn block heights for objective time measurement
- Clarity Bitcoin Library - Bitcoin transaction verification on-chain
- HYPERINSURE_CORE_V2 - Main insurance contract managing policies, purchases, and claims
- Node.js 18+
- pnpm (recommended) or npm/yarn
# Clone the repository
git clone https://github.com/AmaanSayyad/HyperInsure.git
# Navigate to the project directory
cd HyperInsure
# Install dependencies
pnpm install
# or
npm install
# Create environment file
cp .env.example .env.local
# Edit .env.local with your contract addresses and configuration
# Start the development server
pnpm dev
# or
npm run devVisit http://localhost:3000 to view the application.
Create a .env.local file in the root directory with the following variables:
# Network Configuration
NEXT_PUBLIC_NETWORK=testnet
NEXT_PUBLIC_STACKS_API_URL=https://api.testnet.hiro.so
NEXT_PUBLIC_DEPLOYER_ADDRESS=ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V
# Core Insurance Contracts
NEXT_PUBLIC_HYPERINSURE_CORE_V2_CONTRACT=ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.hyperinsure-core-v2
NEXT_PUBLIC_CLARITY_BITCOIN_CONTRACT=ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.clarity-bitcoin
NEXT_PUBLIC_INSURANCE_TREASURY_CONTRACT=ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.insurance-treasury-v2
NEXT_PUBLIC_POLICY_MANAGER_CONTRACT=ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.policy-manager
NEXT_PUBLIC_CLAIM_PROCESSOR_CONTRACT=ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.claim-processor
# Enhanced Contracts
NEXT_PUBLIC_FRONTEND_API_CONTRACT=ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.frontend-api
# Governance and Oracle
NEXT_PUBLIC_GOVERNANCE_CONTRACT=ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.governance
NEXT_PUBLIC_ORACLE_CONTRACT=ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.oracle
# Legacy (if using older contracts)
NEXT_PUBLIC_HYPERINSURE_CORE_CONTRACT=ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.hyperinsure-core
# Bitcoin API Configuration
NEXT_PUBLIC_BITCOIN_API_URL=https://mempool.space/testnet/api
NEXT_PUBLIC_BITCOIN_NETWORK=testnet
NEXT_PUBLIC_MEMPOOL_API_URL=https://mempool.space/testnet/api
NEXT_PUBLIC_CLARITY_BITCOIN_MAINNET=SP2PABAF9FTAJYNFZH93XENAJ8FVY99RRM50D2JG9.clarity-bitcoin-lib-v5
# Explorer
NEXT_PUBLIC_EXPLORER_URL=https://explorer.hiro.so
# Policy Defaults (optional)
NEXT_PUBLIC_DEFAULT_DELAY_THRESHOLD=35
NEXT_PUBLIC_DEFAULT_POLICY_DURATION=1000
NEXT_PUBLIC_MIN_PREMIUM_AMOUNT=100000
NEXT_PUBLIC_MAX_COVERAGE_AMOUNT=100000000000
# Debug Settings (optional)
NEXT_PUBLIC_DEBUG_MODE=false
NEXT_PUBLIC_ENABLE_CONSOLE_LOGS=falseNote: Replace the contract addresses above with your actual deployed contract addresses. The deployer address
ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1Vis an example - use your own deployer address.
See lib/stacks-config.ts for all available configuration options and their default values.
All deployed contracts can be viewed on the Stacks Explorer:
| Contract Name | Contract ID | Explorer Link |
|---|---|---|
| HyperInsure Core V2 | ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.hyperinsure-core-v2 |
View on Explorer |
| Clarity Bitcoin | ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.clarity-bitcoin |
View on Explorer |
| Insurance Treasury V2 | ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.insurance-treasury-v2 |
View on Explorer |
| Policy Manager | ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.policy-manager |
View on Explorer |
| Claim Processor | ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.claim-processor |
View on Explorer |
| Frontend API | ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.frontend-api |
View on Explorer |
| Governance | ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.governance |
View on Explorer |
| Oracle | ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.oracle |
View on Explorer |
| HyperInsure Core (Legacy) | ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1V.hyperinsure-core |
View on Explorer |
Note: Replace
ST19EWTQXJHNE6QTTSJYET2079J91CM9BRQ8XAH1Vwith your actual deployer address in the links above. The contract names should match your deployed contracts.
- Navigate to the Purchase page (
/purchase) - Connect your Stacks wallet
- Select an insurance policy (Starter, Professional, or Enterprise)
- Enter the amount of STX to deposit as premium
- Review premium rate, delay threshold, and protocol fee
- Complete the purchase transaction
- Your purchase ID will be stored and displayed
- Navigate to the Policies page (
/policies) - View available policies created by admins
- See your purchased policies with details:
- Policy name and ID
- Delay threshold
- Premium paid
- Coverage amount
- Expiration status
- Use search and filters to find specific policies
- Get alerts for policies expiring soon
- Navigate to the Verify page (
/verify) - Enter your Bitcoin transaction ID (TX ID)
- Optionally provide broadcast block height
- Click "Analyze Delay" to check:
- Estimated broadcast height
- Confirmation height
- Delay in blocks and minutes
- Fee rate analysis
- Eligibility for claim
- Navigate to the Claim page (
/claim) - Connect your Stacks wallet (must match purchase wallet)
- Select the policy purchase you want to claim for
- Enter your Bitcoin transaction ID
- Optionally provide broadcast block height (or let system estimate)
- Click "Verify & Analyze Delay"
- Review the delay analysis:
- If eligible: Transaction delay exceeds policy threshold
- If not eligible: See why (delay too short, transaction not confirmed, etc.)
- If eligible, click "Submit Claim"
- Receive instant verification and automatic payout if approved
- Navigate to the Admin page (
/admin) - Connect with admin wallet
- Go to "Policies" tab
- Fill in policy details:
- Policy ID (e.g., POL-001)
- Policy name
- Description
- Premium rate (percentage)
- Delay threshold (blocks)
- Protocol fee (percentage)
- Submit transaction to create policy
- Navigate to the Admin page (
/admin) - Go to "Admin Settings" tab
- View current admin address
- Update admin address (requires current admin wallet)
- Submit transaction to change admin
- Navigate to the Admin page (
/admin) - View "Overview" tab for:
- Total policies and purchases
- Total deposits and payouts
- Contract balance and revenue
- System health metrics
- Home (
/): Landing page with features, coverage plans, testimonials, FAQ, and CTA - Policies (
/policies): Dashboard to view available policies and your purchased policies - Purchase (
/purchase): Purchase insurance coverage with STX tokens - Verify (
/verify): Verify Bitcoin transaction delays before submitting claims - Claim (
/claim): Submit insurance claims for delayed Bitcoin transactions - Admin (
/admin): Admin panel for creating policies, managing admin access, and viewing statistics
✅ Policy Management: Admins can create customizable insurance policies
✅ Policy Purchase: Users can purchase coverage with STX tokens
✅ Bitcoin Transaction Verification: Automatic verification of Bitcoin transaction delays
✅ Claim Submission: Submit claims with Bitcoin transaction proofs
✅ Automatic Payouts: Instant payouts when delay exceeds threshold
✅ Real-time Statistics: Admin dashboard with system metrics
✅ Wallet Integration: Seamless Stacks wallet connection
✅ Transaction Tracking: View all purchases and claims on-chain
✅ Policy Expiration Alerts: Notifications for expiring policies
✅ Modern UI/UX: Beautiful, responsive design with glassmorphism effects
We plan to extend HyperInsure to cover additional blockchain risks:
- Wallet theft protection via Arkham
- Transaction failure coverage
- Gas-spike hedging
- Validator risk coverage
- Cross-chain finality protection
- Mobile app for iOS and Android
- Multi-signature wallet support
- Insurance pool sharing
For questions or support, please reach out to us at: